SQLAlchemy doesn't care if your classes are defined in a single file
or multiple files.

When you got the error, is it possible that you hadn't imported
moduleB? If you haven't imported it, SQLAlchemy will have no idea that
ClassB exists.

Simon

On Thu, Jul 4, 2019 at 11:53 AM natsjoo sodillepa <[email protected]> wrote:
>
> Hi all,
>
> I got an "No such polymorphic_identity" error in the following situation:
> - I use Declerative and joined table polymorfism style
> - moduleA defines Base, and a lot of Classes, one of them ClassA1(Base) and 
> ClassA2(Base)
> - moduleB contains a subclassed ClassB(ClassA1)
> - ClassA2 contains a 1:n relation with ClassA1
>
> when I try to get the list of ClassA1 objects of ClassA2 I get a "No such 
> polymorphic_identity"
> error.
>
> However, if I put everything in the same file things work fine.
>
> So my question is: can I put subclasses in different modules and if so: how?
>
> Kind regards,
> Nacho
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/sqlalchemy.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/53a77b0e-b28c-4c1d-a54a-ffac09cfb5be%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexdaHXfV5SBkzXmM2FLJNbfOBgti2Siqkh%2B-1y9RqNNmOA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to