On 5/19/15 6:54 AM, Paul Johnston wrote:
Hi,

Sorry if this is a FAQ, but is it possible to define a relationship and its column all at once. e.g. instead of:

    type_id = db.Column(db.Integer, db.ForeignKey('linktype.id'))
    type = db.relationship('LinkType')

Something like:

    type = db.relationship('LinkType', colname='type_id')

In fact, it'd be good for the colname to default to "xxx_id" - although allow overriding.

This certainly was possible with Elixir.
this would be a many_to_one() macro.  Two examples of this are at:

https://bitbucket.org/zzzeek/pycon2014_atmcraft/src/f50cbe745a197ea7db83569283b703c418481222/atmcraft/model/meta/orm.py?at=master

the above is a modernized improvement on an older example:

http://techspot.zzzeek.org/2011/05/17/magic-a-new-orm/




Paul
--
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+unsubscr...@googlegroups.com <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to