Undefer Hybrid Attributes

49 views
Skip to first unread message

Kent

unread,
Mar 7, 2013, 11:36:37 AM3/7/13
to sqlal...@googlegroups.com
I notice that Hybrid Attributes don't show up as mapper properties (since they are class wide instead of mapper specific, I suppose).  I couldn't find documentation on whether I can "undefer" these?  Or can I create a synonym or column_property from a hybrid attribute in the mapper?

Kent

unread,
Mar 7, 2013, 11:42:47 AM3/7/13
to sqlal...@googlegroups.com
I suppose what I'm really after is a column_property (for class level) and plain descriptor (for instance level), which is exactly what Hybrid attributes are meant to be, but I wanted them to be part of the mapper and undeferred in some cases.

Michael Bayer

unread,
Mar 7, 2013, 12:09:01 PM3/7/13
to sqlal...@googlegroups.com

The hybrid attribute is a Python function that invokes when it's called.  So it doesn't make sense for it to be a column property since there is no attribute to be populated.  "Undeferred" also doesn't make any sense because the hybrid already calls a local in-Python function when accessed at the instance level, not a database call.

A traditional column_property() can be deferred or undeterred, and when called at the instance level will emit SQL to the database.

If you have an attribute that should only populate via SQL, then you need to just use a column_property().



--
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 sqlalchemy+...@googlegroups.com.
To post to this group, send email to sqlal...@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Kent Bower

unread,
Mar 7, 2013, 12:17:57 PM3/7/13
to sqlal...@googlegroups.com
That makes sense,
Thanks,
Kent
You received this message because you are subscribed to a topic in the Google Groups "sqlalchemy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sqlalchemy/kO6KS88-2xU/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to sqlalchemy+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages