You need to specify the join condition here as there are multiple
foreign keys and SA cannot figure out the intended join condition.
So the relations would be:
from_person = relation('Person',
primaryjoin='Person.id==Message.from_person_id',
backref='messages_sent')
to_person = relation('Person',
primaryjoin='Person.id==Message.to_person_id',
backref='messages_rcvd')
Sanjiv
2010/2/11 Timuçin Kızılay <[email protected]>:
> Sorry, I should've send the error logs...
> here is the last few lines of output of:
>
> paster setup-app development.ini
>
> ----------
> Traceback (most recent call last):
> File "/home/tim/tg2env/bin/paster", line 8, in <module>
> load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')()
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py",
> line 84, in run
> invoke(command, command_name, options, args[1:])
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py",
> line 123, in invoke
> exit_code = runner.run(args)
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py",
> line 68, in run
> return super(AbstractInstallCommand, self).run(new_args)
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/command.py",
> line 218, in run
> result = self.command()
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py",
> line 456, in command
> self, config_file, section, self.sysconfig_install_vars(installer))
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py",
> line 598, in setup_config
> mod.setup_app, command, filename, section, vars)
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/PasteScript-1.7.3-py2.6.egg/paste/script/appinstall.py",
> line 612, in _call_setup_app
> func(command, conf, vars)
> File "/home/tim/tg2env/nms/nms/websetup/__init__.py", line 19, in setup_app
> bootstrap.bootstrap(command, conf, vars)
> File "/home/tim/tg2env/nms/nms/websetup/bootstrap.py", line 18, in
> bootstrap
> u = model.User()
> File "<string>", line 4, in __init__
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/SQLAlchemy-0.5.1-py2.6.egg/sqlalchemy/orm/attributes.py",
> line 878, in initialize_instance
> fn(self, instance, args, kwargs)
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/SQLAlchemy-0.5.1-py2.6.egg/sqlalchemy/orm/mapper.py",
> line 1738, in _event_on_init
> instrumenting_mapper.compile()
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/SQLAlchemy-0.5.1-py2.6.egg/sqlalchemy/orm/mapper.py",
> line 661, in compile
> mapper._post_configure_properties()
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/SQLAlchemy-0.5.1-py2.6.egg/sqlalchemy/orm/mapper.py",
> line 689, in _post_configure_properties
> prop.init()
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/SQLAlchemy-0.5.1-py2.6.egg/sqlalchemy/orm/interfaces.py",
> line 405, in init
> self.do_init()
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/SQLAlchemy-0.5.1-py2.6.egg/sqlalchemy/orm/properties.py",
> line 707, in do_init
> self._determine_joins()
> File
> "/home/tim/tg2env/lib/python2.6/site-packages/SQLAlchemy-0.5.1-py2.6.egg/sqlalchemy/orm/properties.py",
> line 796, in _determine_joins
> "many-to-many relation, 'secondaryjoin' is needed as well." % (self))
> sqlalchemy.exc.ArgumentError: Could not determine join condition between
> parent/child tables on relation Message.from_person. Specify a
> 'primaryjoin' expression. If this is a many-to-many relation,
> 'secondaryjoin' is needed as well.
> ----------
>
> Sanjiv Singh yazmış:
>>
>> Hi Timucin,
>>
>> You will have to provide more information, e.g. how you are trying to
>> join the tables? and what errors you are getting? for people to be
>> able to help you.
>>
>> regards
>> Sanjiv
>>
>> 2010/2/11 Timuçin Kızılay <[email protected]>:
>>>
>>> I'm getting errors when I try to join multiple fields from one table to
>>> another. can anybody help me? I'm stuch reading documents for hours with
>>> no
>>> luck.
>>>
>>> here is the table definitions : http://pastebin.com/m1c358058
>>>
>>> ---------
>>>
>>> class Person(DeclarativeBase):
>>> __tablename__ = 'person'
>>> id = Column(Integer,primary_key=True)
>>> name = Column(Unicode(50), index=True, unique=True, nullable=False)
>>> email = Column(Unicode(100), index=True)
>>> address = Column(Unicode(255), index=True)
>>>
>>> #ürün tablosu
>>> class Message(DeclarativeBase):
>>> __tablename__ = 'message'
>>> id = Column(Integer, primary_key=True)
>>> message_text = Column(Unicode(1000), index=True)
>>> from_person_id = Column(Integer, ForeignKey('person.id'),
>>> nullable=False)
>>> from_person = relation('Person', foreign_keys=from_person_id,
>>> backref='messages_sent')
>>> to_person_id = Column(Integer, ForeignKey('person.id'),
>>> nullable=False)
>>> to_person = relation('Person', foreign_keys=to_person_id,
>>> backref='messages_rcvd')
>>>
>>> ------------
>>>
>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "TurboGears" 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/turbogears?hl=en.
>>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" 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/turbogears?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en.