mapper.add_property( 'zzz', relation( llm_mapper, ... ) ) fails with:
ArgumentError: Could not determine join condition between parent/
child tables on relation ....
Specify a 'primaryjoin' expression. If this is a many-to-many
relation, 'secondaryjoin' is needed as well.
but the foreign key exists:
(Pdb) llm_mapper.local_table.foreign_keys
OrderedSet([ForeignKey('public.asl_list_view.asl_id')])
(Pdb) llm_mapper.local_table.foreign_keys[0].column
Column('asl_id', Integer(), table=<asl_list_view>, primary_key=True,
nullable=False)
(Pdb) llm_mapper.local_table.foreign_keys[0].column.table.schema
'public'
(Pdb) mapper.local_table.c['asl_id']
Column('asl_id', Integer(), table=<asl_list_view>, primary_key=True,
nullable=False)
(Pdb) mapper.local_table.c['asl_id'].table.schema
'public'
the problem seems to be in the containes_column Method:
(Pdb) mapper.local_table.c.contains_column
( llm_mapper.local_table.foreign_keys[0].column )
False
A litte workarround solves the problem (expression.py):
def contains_column(self, col):
# have to use a Set here, because it will compare the identity
# of the column, not just using "==" for comparison which will
always return a
# "True" value (i.e. a BinaryClause...)
# orig {
#return col in util.column_set(self)
# }
# workarround {
col_name = "%s" % col
for _c in util.column_set(self):
if col_name == "%s" % _c:
return True
return False
# }
test:
(Pdb) mapper.local_table.c.contains_column
( llm_mapper.local_table.foreign_keys[0].column )
True
...and the property is successfully added
I hope it helps.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---