summaryrefslogtreecommitdiff
path: root/test/sql
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-12-14 17:24:47 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-12-14 17:30:21 -0500
commit0e4c4d7efc08d04c3c0ae960428b08ada37e4a91 (patch)
tree4421c6681b9bc6025c5baccffbe5d61b901c48da /test/sql
parent7d96ad4d535dc02a8ab1384df1db94dea2a045b5 (diff)
downloadsqlalchemy-0e4c4d7efc08d04c3c0ae960428b08ada37e4a91.tar.gz
- 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
Diffstat (limited to 'test/sql')
-rw-r--r--test/sql/test_returning.py25
1 files changed, 25 insertions, 0 deletions
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