New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
many-to-many relationship #18
Comments
The model is based on Association-Object pattern [1]. A different approach then what you used with a secondary table. See the commit where it was added 06f8a09 I guess my reasoning was that if you want to have GroupMember with extra attributes you would add entries of GroupMember's on its own. But for simple case where Association-Object is only a reference it provides a bit of magic for convenience (and it would work same as the secondary table you have just implemented). Are you just trying to understand the code or this is causing trouble for you? [1] http://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html#association-object |
It's not causing trouble necessarily - but it just seems like a confusing API for the developer. The "magic" part is quite confusing when just looking at the YAML. For the most part, relationships are declared with references to the model, except for this one case where it can be declared with a reference to a completely different model inferred from the association (?) SQLAlchemy indicates that the use case for an Association Object should be for any extra columns beyond the foreign keys. The I can fix the bug with |
where does it say that? just because it mentions a use-case it doesn't mean the only reason is that use-case. |
it doesn't say that, but i think WE (this library) should say that as it will make it less confusing by only allowing direct relationship references. |
I personally prefer to use the Association-Object pattern. I think it has some advantages... I think it makes the ORM code easier to read as all tables have a mapper.
Also, fixtures for many-to-many being spelled the same way regardless of how you choose to represent the relation with SQLAlchemy is IMO a very neat feature. If you think it is confusing, maybe it is just the case of adding some notes to docs. Not removing the feature. And as your own code shows, it is possible for both to co-exist without interfering with each other. |
@schettino72 It looks like the
secondary
support I just added is not working as expected, so I've been debugging it.Now that I am really digging into the code and looking at the tests - there is something that doesn't quite make sense to me here.
I would have expected
Group.members
to be a list ofGroupMember
references instead ofProfile
references. Can you explain the current implementation?The text was updated successfully, but these errors were encountered: