On Wed, Oct 1, 2008 at 5:48 PM, alex bodnaru <[EMAIL PROTECTED]> wrote:
> hi gaetan,
>
> On Wed, Oct 1, 2008 at 5:56 PM, Gaetan de Menten <[EMAIL PROTECTED]> wrote:
>>
>> On Wed, Oct 1, 2008 at 4:36 PM, alex bodnaru <[EMAIL PROTECTED]> wrote:
>>
>>> i'm so excited i was asking for functionality you were just at
>>> implementing today.
>>
>> I finally decided to implement it because of your message ;-).
>>
> thank you so much :) . i remembered to have raised this question a few months
> ago, but i was very embarassed to have forgot your answer that time.
> it's great you have implemented it' since sa already has it, and it reflects
> many life situations.
>>> an onetomany relationship would work on a set of records on the many
>>> side, which match
>>> certain field values on the record at the one side. until now, the one
>>> side always
>>> contained the pk fields, which changed now, and the now-source columns
>>> should be specified.
>>
>> *IF* I understand what you mean here, then the answer is: no, you
>> don't need to specify anything: that information is already included
>> in the primaryjoin, which is generated by Elixir.
>>
> so, you mean that the mere inverse will do the work, right?
Yes. Or nothing at all, if there is only one relationship pointing to
the other entity, as in the test:
def test_inverse_has_non_pk_target(self):
class A(Entity):
name = Field(String(60), unique=True)
bs = OneToMany('B')
class B(Entity):
name = Field(String(60))
a = ManyToOne('A', target_column=['name'])
setup_all(True)
a1 = A(name='a1')
b1 = B(name='b1', a=a1)
# does it work before a commit? (does the backref work?)
assert b1 in a1.bs
session.commit()
session.clear()
b = B.query.one()
a = b.a
assert b.a.name == 'a1'
assert b in a.bs
--
Gaƫtan de Menten
http://openhex.org
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en
-~----------~----~----~----~------~----~------~--~---