Association proxy "init" does not work symmetrically
Issue #3235
duplicate
For some reason when I try to define association proxy in the user-keyword example, it only works in one direction but not the other, even if I define the association proxies symmetrically (please see attached code). For instance, I can do user1.keywords.append(keyword1) but not keyword1.users.append(user1). The second one will give a "Key Error".
I traced this behavior to the order of arguments in the UserKeyword.init method. The behavior is correct only one way, depending on the argument order, but never both ways. It is somewhat hard to know the right order of arguments for the collection to work...
Comments (4)
-
repo owner -
repo owner - changed status to wontfix
-
repo owner - changed status to duplicate
Duplicate of #3236.
-
repo owner added #3236 as a catchall for these.
- Log in to comment
there's a feature lots of people want which is missing here, however there's no bug, as the parameters passed to UserKeyword are not passed by name, they are passed positionally, essentially the single argument. so without using the "creator" argument here, only "name" is getting passed to UserKeyword. See http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/associationproxy.html#creation-of-new-values: