-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Property definitions for properties of same name shared between Models with same base class #167
Comments
Here is a slightly improved spec that doesn't need to access
Result:
|
I found a potential fix for the issue. When new subclasses of the common base class get instantiated the
I think another line should be added to the definition of the
I tried doing that and it fixes my new test case as well as the issues that I've been observing in our application. However this change breaks a couple of other unit tests:
These two test cases in property_spec only fail if I run property_spec and base_spec together. When running property_spec on it's own it passes. The two tests fail because one of the test cases in base_spec defines a new property However the test case failure still indicates that my fix could impact functionality that might be require for some use cases. Namely the ability to add properties to a base class after subclasses to this base class have already been defined and still have the new property propagate to the subclasses. So maybe there are better ways to fix this issue? |
My team also encountered this issue in couchrest_model 2.0.4, 2 years after the original posting of this issue. This is a very serious bug that will affect a large group of users. It means that properties with the same name defined in different models cannot have different types. Think about properties like 'status' which might be a String in one model and an Integer in another. The actual result will be that both properties will be cast to either a String or an Int, possibly depending on the order in which the classes are loaded. Is this issue being worked on? |
I've found a conflict between property definitions with the same property name in separate models if these models share a common base class.
Here is a test case to replicate this issue:
And this is the error I get when running rspec:
The problem is that the class attribute
properties_by_name
is shared by all the subclasses that inherit from the same base class.The text was updated successfully, but these errors were encountered: