thiis is what synonym is designed for see
https://docs.sqlalchemy.org/en/latest/orm/mapped_attributes.html?highlight=synonym#synonyms

note the column itself you can retain its name by specifying it as the
first argument like:

    _status = Column("status", ...)


On Thu, Jan 24, 2019 at 6:15 PM Daniel Leon <[email protected]> wrote:
>
> For some columns I want to process it a bit before getting or setting it. For 
> example, I have a column Status, but have to call it _Status to avoid name 
> conflict with its property.
>
> class Task(Base):
>     _Status = Column('Status')
>
> @property
> def Status(self):
>     return f(self._Status)
>
> @Status.setter
> def Status(self, value):
>     self._Status = value
>
> Now whenever I write a query involving Status I must remember to use _Status. 
> If I accidentally use Status in a query, it adds WHERE 0 = 1, thus returning 
> nothing, so it fails and I don't know why.
>
> I'm converting from SQLObject where you can call the column Status and define 
> getter and setter by defining functions _get_Status and _set_Status. When I 
> access Status in a query SQLObject knows to use the Column and outside a 
> query it uses _get_Status.
>
> How can I get this behaviour with SQLObject?
>
> --
> 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 post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to