Can I use a field from a related table as the polymorphic descriminator?
This code no works:
http://pastebin.com/LtRC2tSR
Schematically:
class Reference:
reference_id
reference_name
class Parent:
parent_id
reference_id(ForeignKey='reference.reference_id')
reference = relationship(Reference, useList=False)
__mapper_args__ {
polymorphic_on: reference.reference_name
}
class Child
child_id(ForeignKey='parent.parent_id')
child_property
__mapper_args__ {
polymorphic_identity: "some value of reference.name"
}
I also tried an association_proxy but I get sqlalchemy.exc.ArgumentError:
Only direct column-mapped property or SQL expression can be passed for
polymorphic_on
I guess there is someway to extract the SQL emitted by the relationship and
use that as the value of polymorphic_on? Or do I have to use something
like:
select([Reference.reference_name].join(Parent)
Thanks
Ben
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.