I don't understand how to use the "two" fields created in a ManyToOne 
relationship?

 From the tutorial, as below, Elixir will create (in Python) two fields: 
'director' and 'director_id'. How are they used? And how are they kept in sync?

     class Movie(Entity):
         director = ManyToOne('Director')

     class Director(Entity):
     #    movies = OneToMany('Movie')

     d = Director(name="George")
     m = Movie(director=d)
     print m.director, m.director_id

The output will be something like:

     <Director "George">  None

This seems inconsistent. The 'director_id' field makes it appear if there is 
no director assigned to 'm'. But 'director' clearly holds a Director object.

Is this not dangerous? When do you use one or the other?

If 'director_id' is just a shortcut, wouldn't it be more correct and safe to 
just refer to 'm.director.id'?

Note that this is complicated, IMHO, by the fact that m.table.c contains 
'director_id'  rather than 'director' (the more useful attr).

I'm obviously just not getting it, can someone expound on this a bit?

Thanks,
Michael


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to