-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[WIP] SQLAlchemy 2.0 follow-up: misc. improvements #19417
base: dev
Are you sure you want to change the base?
Conversation
We have 168 model classes most of which have the same
However, this will cause errors when that column is used to specify other properties in a class. In the example above, the Another neat refactoring that doesn't always work. If we replace
I'll check for more info on the above, but overall, I think, we should be cautious in applying SA 2.0 model definition syntax optimizations. UPDATE: it seems to be as simple as using the callable form for |
8889d8e
to
8f40a12
Compare
The id attribute is used in the definition of the `update_time` column_property. Since id is inherited from a mixin, it is not available on the History class at mapping time. The `remote_side` and `foreign_keys` parameters of the relationship function face the same problem; however they can be defined as a callable, which defers resolving the identifiers they contain, which solves this problem. `column_property` does not accept a callable in place of its argument, so the only way around is to define it after the class has been defined - and we do so for several classes (see bottom of the model/__init__ module. However, it appears to be impossible to use this approach for the update_time attribute because it is also the name of the database table column, which is defined inside the class definition. Moving that column definition outside the class would add unnecessary complexity: redefining the id column, I think, is the reasonable approach here.
(Please replace this header with a description of your pull request. Please include BOTH what you did and why you made the changes. The "why" may simply be citing a relevant Galaxy issue.)
(If fixing a bug, please add any relevant error or traceback)
(For UI components, it is recommended to include screenshots or screencasts)
How to test the changes?
(Select all options that apply)
License