column_property and relationship

15 views
Skip to first unread message

Nagy Viktor

unread,
Dec 3, 2010, 5:15:33 AM12/3/10
to sqlal...@googlegroups.com

Hi,

is it possible to define a relationship over a column property?

the column property returns an id, and it would be nice to get the related object via a relationship easily.

I've tried a couple of things, but the didn't work out, like:

    production_request_id = column_property(
        select([ProductionRequests.id])\
            .where(ProductionRequests.id==cast(func.substring(nr_proforma, 3), Integer))\
            .where(ProductionRequests.type==func.substring(nr_proforma, 1, 2)),
        deferred=False
        )

    production_request = relationship(ProductionRequests,
        primaryjoin=production_request_id==ProductionRequests.id)

gives

ArgumentError: Could not determine relationship direction for primaryjoin condition 'documenteiesire."IDDoc" = :IDDoc_1', on relationship ProductionOrders.production_request. Ensure that the referencing Column objects have a ForeignKey present, or are otherwise part of a ForeignKeyConstraint on their parent Table

How could I define a ForeignKey as there is no real column?

thanks, Viktor

Reply all
Reply to author
Forward
0 new messages