I maintain Aldjemy, a library that converts Django models into SQLAlchemy 
models. I'm having some trouble figuring out how I should resolve an issue 
I'm working on, and I could use your help. Here's the link to the issue I'm 
working on, though hopefully the context I give below will be sufficient.

https://github.com/aldjemy/aldjemy/issues/159

Django models many to many relationships with a ManyToManyField on one side 
of the relationship, and an automatically added reverse relationship on the 
other side. Depending on how you configure it, it will either automatically 
create the intermediate table, or you can manually specify it. Either way, 
the "through" model, representing the intermediate table, is a 
fully-functional model, with the appropriate foreign key relationships.

Aldjemy models this currently by creating a relationship for each of the 
foreign key relationships on the secondary (through) table, as well as a 
relationship (notably missing the backref, though fixing that isn't my 
priority right now) that includes the `secondary` argument to make it model 
the many-to-many relationship.

Starting with SQLAlchemy 1.4, this gives warnings that these relationships 
conflict, and suggesting that these conflicting relationships either need 
to have one be read-only, or use the "overlaps" parameter to specify that 
we know about this, and it's what we intend. However, I think this is a 
strong indication that this is *not* how we should be modeling this.

Mark over in IRC suggested that he'd model it either by dropping the 
relationship with the secondary table, or by replacing that relationship 
with an association proxy. If the either is present, it should give access 
to model instances, so I wasn't immediately sure if an association proxy 
would be able to do that, but it does seem like it's possible. It seems 
from some experiments he did that an association proxy would not be able to 
be used to do join.

How would you recommend I model this in Aldjemy? I figure whatever I choose 
is technically going to be a breaking change, so I'd like to choose the 
wisest option, that most cleanly fits into the patterns that SQLAlchemy 
users will most readily understand.

Thank you,

Ryan




-- 
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/cdcecf3a-3e11-441f-bd96-3216d76ffc42n%40googlegroups.com.

Reply via email to