You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.
Hi,
Been using (and loving) attrs_sqlalchemy for a large VR project and it's recently stopped working after I updated to the latest sqlalchemy (version above).
Here's proof-of-concept code with the traceback:
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_base
from attrs_sqlalchemy import attrs_sqlalchemy
engine = create_engine('sqlite:///:memory:')
class _Base:
id = Column(Integer, primary_key=True)
Base = declarative_base(bind=engine, cls=_Base)
@attrs_sqlalchemy
class Object(Base):
__tablename__ = 'objects'
name = Column(String(50), nullable=True)
Base.metadata.create_all()
o = Object()
print(repr(o))
And here's the TB:
Traceback (most recent call last):
File "test.py", line 25, in <module>
print(repr(o))
File "c:\Users\chris\envs\mindspace-server\lib\site-packages\attr\_make.py", line 814, in repr_
for name in attr_names
File "c:\Users\chris\envs\mindspace-server\lib\site-packages\attr\_make.py", line 814, in <genexpr>
for name in attr_names
AttributeError: 'Object' object has no attribute 'name'
I'd be happy to go and try and affect a fix but I have no idea how. I'm going to start reading through your code and I will do my best to sort it myself. Do you have any pointers that might aid me in this? Of course if you fix it first that would be awesome! :-)
Cheers,
Chris
The text was updated successfully, but these errors were encountered:
I ran into this same problem... it looks like it's due to a breaking change in the attrs package: python-attrs/attrs#253
SQLAlchemy's declarative mode relies on setting class attributes to represent columns. When attrs >= 17.3.0 processes the class, I think it's stripping out those attributes and replacing them with some other mechanism. This results in the AttributeError that you encountered above.
Unfortunately, I don't know enough about the inner workings of attrs to propose a fix -- for now, I'm working around the issue by just pinning the attrs version to 17.2.0.
Hi,
Been using (and loving) attrs_sqlalchemy for a large VR project and it's recently stopped working after I updated to the latest sqlalchemy (version above).
Here's proof-of-concept code with the traceback:
And here's the TB:
I'd be happy to go and try and affect a fix but I have no idea how. I'm going to start reading through your code and I will do my best to sort it myself. Do you have any pointers that might aid me in this? Of course if you fix it first that would be awesome! :-)
Cheers,
Chris
The text was updated successfully, but these errors were encountered: