Hi, so I have the database classes as follows:

class Thing(Base):


DatasetId = Column(ForeignKey(schema + 'Dataset.DatasetId'), 
primary_key=True, nullable=False, index=True)

RequiredThing_child = relationship('RequiredThing', cascade='all, 
delete-orphan')

class Location(Base):


DatasetId = Column(ForeignKey(schema + 'Dataset.DatasetId'), 
primary_key=True, nullable=False, index=True)

RequiredThing_child = relationship('RequiredThing', cascade='all, 
delete-orphan')

class RequiredThing(Base): 


DatasetId = Column(ForeignKey(schema + 'Dataset.DatasetId'), 
primary_key=True, nullable=False, index=True)

Thing= relationship('Thing', viewonly=True) Location= 
relationship('Location', viewonly=True)

(There are more relationships on both tables but these ones are the only 
ones that I've had issues with, as they both have that column).  


I set them up like that because I want to have the cascade deletion 
functionality: whenever I call for a deletion of a thing object I want the 
children (in this case RequiredThing) to be deleted as well (as long as it 
matches with the Thing Id). When I had it active for only one table (in 
this case Thing), it worked fine but now that I also added the relationship 
for the Location table it's giving me the following warning: 

SAWarning: relationship 'Location.RequiredThing_child' will copy column 
Location.DatasetId to column RequiredThing.DatasetId, which conflicts with 
relationship: 'Thing.RequiredThing_child' (copies Thing.DatasetId to 
RequiredThing.DatasetId).

I've tried to add back_populates to the RequiredThing class but to no avail.
I need this to work because I want to implement the cascade functionality 
to many more tables as needed but I do not want there to be any errors or 
ambiguity when running the queries.
Or if there's a better way to implement cascade deletion I'm all for it.
Any suggestions or corrections to my code would be greatly appreciated!

Kind regards,

Javier

(reposted to edit the paragraphs)

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/eb7201ef-32d5-4858-8b00-5fd6349a2c6dn%40googlegroups.com.

Reply via email to