Association proxy for composites has stopped working from version 1.3
See original GitHub issueI am getting below error in my application:
api_1 | File "/app/src/hoist/api/application/AppService.py", line 509, in create_app_field_config
api_1 | field.references = settings.references or ()
api_1 | File "/cache/local/lib/python2.7/site-packages/sqlalchemy/ext/associationproxy.py", line 202, in __set__
api_1 | return self._as_instance(class_, obj).set(obj, values)
api_1 | File "/cache/local/lib/python2.7/site-packages/sqlalchemy/ext/associationproxy.py", line 249, in _as_instance
api_1 | inst = AssociationProxyInstance.for_proxy(self, owner, obj)
api_1 | File "/cache/local/lib/python2.7/site-packages/sqlalchemy/ext/associationproxy.py", line 381, in for_proxy
api_1 | target_assoc, parent, owning_class, target_class, value_attr
api_1 | File "/cache/local/lib/python2.7/site-packages/sqlalchemy/ext/associationproxy.py", line 398, in _construct_for_assoc
api_1 | is_object = attr._impl_uses_objects
api_1 | File "/cache/local/lib/python2.7/site-packages/sqlalchemy/orm/attributes.py", line 393, in __getattr__
api_1 | attribute,
api_1 | AttributeError: Neither 'property' object nor 'Comparator' object associated with ApplicationFieldReference.ref has an
attribute '_impl_uses_objects'
The classes that i have loosely looks like:
class ApplicationFieldReference(Base):
__tablename__ = "app_field_ref"
field_id = Column(Integer, ForeignKey("app_field.field_id"), primary_key=True)
ref_type = Column(EnumType(30, ReferenceType), primary_key=True)
ref_id = Column(Integer, primary_key=True, autoincrement=False)
ref = composite(Reference, ref_type, ref_id)
class ApplicationField(Base, BaseApplicationField):
__tablename__ = "app_field"
field_id = Column(Integer, primary_key=True)
app_id = Column(Integer, ForeignKey("app.app_id"), nullable=False)
app = relation("Application")
type = Column(Unicode(120), nullable=False)
config = relation(ApplicationFieldConfig,
primaryjoin=and_(field_id == ApplicationFieldConfig.field_id,
ApplicationFieldConfig.revision_to == None),
uselist=False,
viewonly=True)
_references_relation = relation("ApplicationFieldReference", cascade='all, delete-orphan',
primaryjoin=field_id == ApplicationFieldReference.field_id)
references = association_proxy('_references_relation', 'ref',
creator=lambda ref: ApplicationFieldReference(ref=ref))
Things are working fine with sqlalchemy till version 1.2.19; but, 1.3 onward, it started throwing the above error.
I checked a little bit, and the commit 90574aabef36fd59841b7df7d8ac30e2030e9854, is where it starts failing.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Association Proxy — SQLAlchemy 1.4 Documentation
New in version 1.3: - AssociationProxy no longer stores any state specific to a particular parent class; the state is now stored in ......
Read more >association proxy through composite key relation not working ...
I have to association proxies in code one is working and other not. I went through it many times and wasnt able to...
Read more >Association Proxy - SQLAlchemy 1.1 Documentation
associationproxy is used to create a read/write view of a target attribute across a relationship. It essentially conceals the usage of a “middle”...
Read more >Association Proxy - 《SQLAlchemy 1.3 Documentation》
Association Proxy. associationproxy is used to create a read/write view of atarget attribute across a relationship.
Read more >SysML Full Ports versus Proxy Ports - Model Based Systems ...
Besides others the new version 1.3 introduced the concept of full and proxy ports. Full port. A full port is an element of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @zzzeek, the issue is resolved now. All my project’s testcases, which were failing because of this, are passing. Thank you for quickly fixing it.
there’s a patch that you can download from https://gerrit.sqlalchemy.org/changes/1590/revisions/6bef95307862286f1d53b887c20d03344284d948/patch?zip , or otherwise use one of the methods in the top right of https://gerrit.sqlalchemy.org/#/c/sqlalchemy/sqlalchemy/+/1590/ . if you can confirm this resolves your issue and there are no further issues that would add more confidence to this, although I’m pretty sure I got the immediate issue you are having.