sqlalchemy-history
sqlalchemy-history copied to clipboard
Fix builder not copying hybrid_property.expr and other props to the version class
Found and fixed the bug in Builder.create_hybrid_properties. It was only copying the python hybrid property function to the corresponding version class but not the SQL equivalent, thus we would get the error below:
self = <class 'sqlalchemy_history.model_builder.ArticleVersion'>
@sa.ext.hybrid.hybrid_property
def author_name(self):
> return self.author.name
E AttributeError: 'property' object has no attribute 'name'
tests/test_hybrid_property.py:37: AttributeError
================================================================================================= short test summary info ==================================================================================================
FAILED tests/test_hybrid_property.py::TestHybridProperty::test_version_class_hybrid_property_in_sql_expression - AttributeError: 'property' object has no attribute 'name'
Thanks for fixing it, we ran into problems here as well!
@aditya051293 Would you mind having a look?