On Mar 28, 2014, at 1:15 AM, Adrian Robert <[email protected]> wrote:
> I have been using the automap extension with postgres, with an inheritance
> structure using the joined inheritance pattern. I could not figure out a way
> to have this reflected from the DB so I define the classes for this part of
> my schema explicitly, and when automap initializes, these classes get used
> (and modified) for those tables and the rest get autogenerated.
>
> It works fine until I try to delete an instance of an inheriting class: then
> I get a circular dependency error which seems to relate to relationships and
> backreferences created for the foreign key relationship underlying the joined
> inheritance.
>
> The attached code demonstrates the issue. The first run generates the DB
> schema from the classes, and works, any number of times. On the second run,
> switch the two comments for Base (in two places) to use automap. The output
> of the first:
>
> % ./test.py
> RELATIONSHIPS: []
> Run completed successfully.
>
> % ./test.py
> RELATIONSHIPS: [('employee', <RelationshipProperty at 0x10263d310;
> employee>), ('engineer_collection', <RelationshipProperty at 0x102663210;
> engineer_collection>)]
> Circular dependency detected. Cycles: {DeleteState(<Engineer at
> 0x1026a9d10>)} all edges: {(DeleteState(<Engineer at 0x1026a9d10>),
> DeleteState(<Engineer at 0x1026a9d10>)),
> (ProcessState(OneToManyDP(Employee.engineer_collection), <Engineer at
> 0x1026a9d10>, delete=True), DeleteState(<Engineer at 0x1026a9d10>))}
>
> Notice that the mapper in the first case shows no relationships, despite the
> foreign key created for the inheritance. On the other hand when the same
> structure is read from the DB by automap, we see forward and back
> relationships, which I guess is somehow causing the circular dependency.
>
> Am I doing something wrong in my attempt to use joined inheritance in
> conjunction with automap, or is this a bug or something unsupported?
automap is creating an inappropriate relationship. I added a rule to skip
relationship for issubclass(local_cls, target_cls) in 4d93a52e77895f87570,
issue #3004.
--
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.
For more options, visit https://groups.google.com/d/optout.