From 0e4c4d7efc08d04c3c0ae960428b08ada37e4a91 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 14 Dec 2015 17:24:47 -0500 Subject: - Fixed bug in :meth:`.Update.return_defaults` which would cause all insert-default holding columns not otherwise included in the SET clause (such as primary key cols) to get rendered into the RETURNING even though this is an UPDATE. - Major fixes to the :paramref:`.Mapper.eager_defaults` flag, this flag would not be honored correctly in the case that multiple UPDATE statements were to be emitted, either as part of a flush or a bulk update operation. Additionally, RETURNING would be emitted unnecessarily within update statements. fixes #3609 --- test/sql/test_returning.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/sql') diff --git a/test/sql/test_returning.py b/test/sql/test_returning.py index cd9f632b9..77a0c6007 100644 --- a/test/sql/test_returning.py +++ b/test/sql/test_returning.py @@ -387,6 +387,31 @@ class ReturnDefaultsTest(fixtures.TablesTest): {"data": None, 'upddef': 1} ) + def test_insert_all(self): + t1 = self.tables.t1 + result = testing.db.execute( + t1.insert().values(upddef=1).return_defaults() + ) + eq_( + dict(result.returned_defaults), + {"id": 1, "data": None, "insdef": 0} + ) + + def test_update_all(self): + t1 = self.tables.t1 + testing.db.execute( + t1.insert().values(upddef=1) + ) + result = testing.db.execute( + t1.update(). + values(insdef=2).return_defaults() + ) + eq_( + dict(result.returned_defaults), + {'upddef': 1} + ) + + class ImplicitReturningFlag(fixtures.TestBase): __backend__ = True -- cgit v1.2.1