[Sqlalchemy-tickets] Issue #3556: update executemany() enhancement breaks versioning (zzzeek/sqlalc
Brought to you by:
zzzeek
|
From: Mike B. <iss...@bi...> - 2015-10-19 16:01:24
|
New issue 3556: update executemany() enhancement breaks versioning https://bitbucket.org/zzzeek/sqlalchemy/issues/3556/update-executemany-enhancement-breaks Mike Bayer: ``` #!diff diff --git a/test/orm/test_versioning.py b/test/orm/test_versioning.py index d46799c..67d580e 100644 --- a/test/orm/test_versioning.py +++ b/test/orm/test_versioning.py @@ -952,6 +952,46 @@ class ServerVersioningTest(fixtures.MappedTest): ) self.assert_sql_execution(testing.db, sess.flush, *statements) + def test_multi_update(self): + sess = self._fixture() + + f1 = self.classes.Foo(value='f1') + f2 = self.classes.Foo(value='f2') + f3 = self.classes.Foo(value='f3') + sess.add_all([f1, f2, f3]) + sess.flush() + + f1.value = 'f1a' + f2.value = 'f2a' + f3.value = 'f3a' + + statements = [ + # note that the assertsql tests the rule against + # "default" - on a "returning" backend, the statement + # includes "RETURNING" + CompiledSQL( + "UPDATE version_table SET version_id=2, value=:value " + "WHERE version_table.id = :version_table_id AND " + "version_table.version_id = :version_table_version_id", + lambda ctx: [ + { + "version_table_id": 1, + "version_table_version_id": 1, "value": "f2"}] + ) + ] + if not testing.db.dialect.implicit_returning: + # DBs without implicit returning, we must immediately + # SELECT for the new version id + statements.append( + CompiledSQL( + "SELECT version_table.version_id " + "AS version_table_version_id " + "FROM version_table WHERE version_table.id = :param_1", + lambda ctx: [{"param_1": 1}] + ) + ) + self.assert_sql_execution(testing.db, sess.flush, *statements) + def test_delete_col(self): sess = self._fixture() ``` PG: ``` #! File "/Users/classic/dev/sqlalchemy/test/../lib/sqlalchemy/engine/result.py", line 1026, in fetchone self.cursor, self.context) File "/Users/classic/dev/sqlalchemy/test/../lib/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception exc_info File "/Users/classic/dev/sqlalchemy/test/../lib/sqlalchemy/util/compat.py", line 199, in raise_from_cause reraise(type(exception), exception, tb=exc_tb) File "/Users/classic/dev/sqlalchemy/test/../lib/sqlalchemy/engine/result.py", line 1017, in fetchone row = self._fetchone_impl() File "/Users/classic/dev/sqlalchemy/test/../lib/sqlalchemy/engine/result.py", line 898, in _fetchone_impl return self.cursor.fetchone() ProgrammingError: (psycopg2.ProgrammingError) no results to fetch ``` |