Duplicate join table rows created when modifying contents of InstrumentedList in many-to-many relationship.
(original reporter: anthonyt) Like the title says, this is a test case for a bug that affects setting the contents of an InstrumentedList property.
Essentially it boils down to: If there is an object X in a Many-To-Many relationship with a join table, and you remove it, then add it again, then flush, SQLAlchemy tries to insert a duplicate row into the join table.
e.g. given the following... tables: users, groups, users_groups classes: User, Group and instances: u, g
The following operations will succeed:
u.groups = [g](g)
session.commit()
u.groups.remove(g)
session.commit()
u.groups.append(g)
session.commit()
But the following operations (missing the intermediate flush/commit) will fail:
u.groups = [g](g)
session.commit()
u.groups.remove(g)
u.groups.append(g)
session.commit()
Runnable test case at https://gist.github.com/4449077 though you'll have to edit the config dictionary to add your own user and database name.
Comments (6)
-
Account Deleted -
repo owner - changed milestone to 0.8.0final
as I read this I was thinking I'd see "dynamic" in there, and sure enough. Please see http://docs.sqlalchemy.org/en/latest/changelog/changelog_08.html#change-30c07492fc86836cb428a07cb6a8c472 as well as
#2637, this is likely a duplicate which has been fixed. If you can confirm here that would be great else I'll try running tomorrow. -
Account Deleted (original author: anthonyt) Looks like it's probably the same problem, but I haven't had a chance to actually test it out. The change is implemented in an unreleased branch of 0.8.0, right? What's the best way to get a hold of that?
-
repo owner there's always links to the various branches on http://www.sqlalchemy.org/download.html, where you can get the latest 0.8 via http://hg.sqlalchemy.org/sqlalchemy/archive/default.tar.gz.
-
repo owner - changed status to duplicate
test runs fine in 0.8 and for the moment
#2637isn't being backported. -
repo owner - removed milestone
Removing milestone: 0.8.0final (automated comment)
- Log in to comment
(original author: anthonyt) I should add that I'm using 0.7.9 on Python 2.7.3