Modify mappings to support casting for polymorphic relations.

Issue #1348 resolved
Former user created an issue

I was running into a case where I wanted to support a polymorphic one to many relation, where the different related tables have primary keys of different types. The mapper was not allowing that. I provide a patch and a bit of example code which expresses a possible fix.

Comments (6)

  1. Mike Bayer repo owner
    • changed component to orm

    seems like a dupe of #610. please provide patches in unified diff format against the SQLAlchemy trunk.

  2. Mike Bayer repo owner

    thanks. im not thrilled about the explicit check for cast_() and wonder if there's some better way to do that, but I'll have a look at this.

  3. Mike Bayer repo owner

    this is a dupe of #610 and the approach in the given patch is not nearly generalized enough for a core feature add. The _local_remote_pairs argument allows total control of mapper functionality independently of primaryjoin, so its essentially available. See the example I attached to #610.

  4. Log in to comment