-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
When using psycopg2 with use_batch_mode=True, false delete warnings are issued #4661
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
Comments
Just to make it clear: in all cases the correct number of rows are deleted. This is merely an issue with the reported rowcount. |
the rowcount should not be consulted if the dialect reports supports_sane_multi_rowcount=False which is the case for use_batch_mode=True so this a bit of a mystery. |
Mike Bayer has proposed a fix for this issue in the master branch: Don't warn on multi delete rowcount if supports_sane_multi is False https://gerrit.sqlalchemy.org/1249 |
Mike Bayer has proposed a fix for this issue in the rel_1_3 branch: Don't warn on multi delete rowcount if supports_sane_multi is False https://gerrit.sqlalchemy.org/1250 |
we were just warning in the ORM. old bug |
Accidentally filed this under my girlfriend's Github account. Awesome! Thanks for the fix. |
Fixed an issue where the "number of rows matched" warning would emit even if the dialect reported "supports_sane_multi_rowcount=False", as is the case for psycogp2 with ``use_batch_mode=True`` and others. Fixes: #4661 Change-Id: I93aaf7f597b6083e860ab3cbcd620ba5621c57a8 (cherry picked from commit aa94afc)
the fix for this is wrong, tests fail for a DB that doesnt have sane multi row count. additionally, the dialect should be supporting -1 for rowcount if this is not supported. |
Mike Bayer has proposed a fix for this issue in the master branch: Correct fix and tests for #4661 https://gerrit.sqlalchemy.org/1262 |
Mike Bayer has proposed a fix for this issue in the rel_1_3 branch: Correct fix and tests for #4661 https://gerrit.sqlalchemy.org/1263 |
For #4661 we need to still warn if we are only deleting one row, even if sane multi rowcount is false. Tests were failing for pyodbc since the warning was removed for the single-row case. the UPDATE logic raises if a single row doesn't match even if sane multi rowcount is false, so this is now more consistent with that. Add tests for the UPDATE case also. It is possible there are already tests for this but as the DELETE case wasn't well covered it's not clear. Fixes: #4661 Change-Id: Ie57f765ff31bf806206837c5fbfe449b02ebf4be (cherry picked from commit bdafff8)
I'm using psycopg2 with use_batch_mode=True. I have a parent child relationship with two children. If I delete the parent, SQL Alchemy gives me the following warning:
This does not happen if I don't use batch mode.
Drilling down, the warning is issued in sqlalchemy/orm/persistence.py around line 1300 (on current master). The problem is that the delete query on line 1329 reports an incorrect row count. Even though the query deletes two rows, the rowcount is 1.
The following is a script that reproduces this error. It reproduces both the false warning and the problem whereby rowcount is incorrect:
The text was updated successfully, but these errors were encountered: