thanks Mike!
the problem is that the other side is also a selectable, so:
foo = relationship("Remote", primaryjoin=myselect.c.foo ==
myotherselect.c.bar)
myselect.c.foo *is* a foreign key to some table primary key that is the
value of myotherselect.c.bar, but i can't figure out why or how to make
foreign keys to be detected, basically because i'm trying to use some
weird postgres queries using recursivity and connect paths, so in the
end the error I always get is:
/path/to/lib/python2.7/site-packages/sqlalchemy/sql/elements.pyc in
_only_column_elements(element, name)
3348 raise exc.ArgumentError(
3349 "Column-based expression object expected for argument "
-> 3350 "'%s'; got: '%s', type %s" % (name, element, type(element)))
3351 return element
3352
ArgumentError: Column-based expression object expected for argument
'foreign_keys'; got: 'None', type <type 'NoneType'>
perhaps i'm asking too much of everything? :)
best regards,
richard.
Em 2014-05-11 00:01, Michael Bayer escreveu:
> On May 10, 2014, at 7:13 PM, Richard Gerd Kuesters <[email protected]>
> wrote:
>
>> hi all!
>>
>> situation: i'm mapping a select as a class, using mapper. so far so good.
>>
>> problem: some of my selected columns *are* foreign keys in their respective
>> tables, but i would like to say to sqla that they're foreign keys to another
>> mapped class, which have the pks from which those fks are pointing.
>>
>> the first question is: how? or
>
> should be able to use relationship(), set up primaryjoin with foreign()
>
> foo = relationship("Remote", primaryjoin=myselect.c.foo ==
> foreign(table.c.foo))
>
> it's a little weird i guess, should work out in modern versions
>
>> the second question: is there a way to inherit properties (like fks) OR
>> "cheat" declaring foreign keys that doesn't exists at the database level ?
>
> sure, use ForeignKey() on your Column(), doesn't matter if it's not in the
> DB, or use in relationship foreign_keys / foreign() annotation
>
>> my best regards,
>>
>> richard.
--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.