Hello,

I wondered if it is possible to use a class mapped against multiple
tables as a relationship() in another class?

something like:

### Content

content_translation_join = sql.join(
  t_content, t_content_translation
)

orm.mapper(
  ContentTranslation, content_translation_join,
  polymorphic_on=t_content.c.content_type_id
)

orm.mapper(
  Content, t_content,
  polymorphic_on=t_content.c.content_type_id,
  properties={
    'translations': orm.relationship(
      ContentTranslation,
      # more stuff here
    )
  }
)

### Document

orm.mapper(
  DocumentTranslation, t_document_translation,
  inherits=ContentTranslation,
  polymorphic_identity=some_id
)

orm.mapper(
  Document, t_document,
  inherits=Content,
  polymorphic_identity=some_id
)

I tried (1) but it doesn't seems to work so I want to be sure that it's
not possible :)

Thanks!
Julien

(1) 
https://gist.github.com/silenius/561b13f4b987c36434cd81e2c08cab6e#file-foo-py



-- 
Julien Cigar
Belgian Biodiversity Platform (http://www.biodiversity.be)
PGP fingerprint: EEF9 F697 4B68 D275 7B11  6A25 B2BB 3710 A204 23C0
No trees were killed in the creation of this message.
However, many electrons were terribly inconvenienced.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: PGP signature

Reply via email to