I have two classes like this:
------------------------------------------------------------------------------------
from elixir import *
from sqlalchemy.databases import mysql
class Customer(Entity):
customer_id = Field(mysql.MSInteger, primary_key=True)
contact_person = ManyToOne('Person')
code = Field(mysql.MSString(8))
name = Field(mysql.MSString(100))
------------------------------------------------------------------------------------
from elixir import *
from sqlalchemy.databases import mysql
class Person(Entity):
person_id = Field(mysql.MSInteger, primary_key=True)
customer = ManyToOne('Customer')
name = Field(mysql.MSString(100))
------------------------------------------------------------------------------------
and they're mapped like this:
mappers['customer'] = mapper(Customer, tables['customer'],
properties = {
'person': relation(Person)
})
mappers['person'] = mapper(Person, tables['person'],
properties = {
'customer': relation(Customer)
})
This cause an error message like this:
Error determining primary and/or secondary join for relationship
'Customer.person (Person)'. If the underlying error cannot be
corrected, you should specify the 'primaryjoin' (and 'secondaryjoin',
if there is an association table present) keyword arguments to the
relation() function (or for backrefs, by specifying the backref using
the backref() function with keyword arguments) to explicitly specify
the join conditions. Nested error is "Can't determine join between
'customer' and 'person'; tables have more than one foreign key
constraint relationship between them. Please specify the 'onclause' of
this join explicitly."
Isn't Elixir supposed to do primary and secondary joins automaticly?
What have I done wrong?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---