here's the migration note that includes this information: https://docs.sqlalchemy.org/en/13/changelog/migration_12.html#hybrid-attributes-support-reuse-among-subclasses-redefinition-of-getter
On Thu, Dec 19, 2019, at 7:18 PM, Mike Bayer wrote: > hiya - > > going to say right off this is the naming issue, there's an unfortunately > stalled PR to make sure the documentation emphasizes this at > https://github.com/sqlalchemy/sqlalchemy/pull/4970 . basically the same note > as you see in > https://docs.sqlalchemy.org/en/13/orm/extensions/hybrid.html#defining-expression-behavior-distinct-from-attribute-behavior. > basically you are assigning your setter function to a brand new hybrid > called "email_setter". name it "def email(self, val)" instead. > > > On Thu, Dec 19, 2019, at 3:34 PM, YKdvd wrote: >> We have a "Users" model with this, which was a hybrid property to wrap the >> "email" column temporarily. The database column (MySQL 5.7) is "email", but >> defined by ORM as "_email", with an "email" hybrid property to access and >> set: >> >> _email = Column(*u'email'*, String(255)) >> ... >> @hybrid_property >> def email(self): >> return self._email.replace("olddomain.com", "newdomain.com") >> @email.setter >> def email_setter(self, val): >> self._email = val >> >> In 1.1.18, something like "self.email = someEmailAddress" works fine. We're >> testing an upgrade to 1.3.11, and that now throws an "AttributeError: can't >> set attribute" from hybrid.py __set__(). >> That seems to be at a simple check "if self.fset *is *None", so it's almost >> as if the decorator never stored the setter function? I'm digging into the >> hybrid docs, and it seems a pretty innocuous setter, but there might be >> something about it that >> 1.3 is being stricter about? I don't see any SAwarnings at startup that >> might apply. I changed the getter to simply return self._email in case that >> was a problem, but that didn't help. >> >> -- >> SQLAlchemy - >> The Python SQL Toolkit and Object Relational Mapper >> >> http://www.sqlalchemy.org/ >> >> To post example code, please provide an MCVE: Minimal, Complete, and >> Verifiable Example. See http://stackoverflow.com/help/mcve for a full >> description. >> --- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/sqlalchemy/eb31b100-a9e1-4ddc-9b76-d8a7651bb4dc%40googlegroups.com >> >> <https://groups.google.com/d/msgid/sqlalchemy/eb31b100-a9e1-4ddc-9b76-d8a7651bb4dc%40googlegroups.com?utm_medium=email&utm_source=footer>. > > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > You received this message because you are subscribed to the Google Groups > "sqlalchemy" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/7ac22728-ef48-4b33-83d5-12efcb7b66a4%40www.fastmail.com > > <https://groups.google.com/d/msgid/sqlalchemy/7ac22728-ef48-4b33-83d5-12efcb7b66a4%40www.fastmail.com?utm_medium=email&utm_source=footer>. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/d5cc7995-0d29-4ce4-8648-af8eb05f49ad%40www.fastmail.com.
