summaryrefslogtreecommitdiff
path: root/test/orm
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2015-12-14 17:39:50 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2015-12-14 17:39:50 -0500
commit26ed90ab22dde7bdafe933cb1d16acfe70c1ab78 (patch)
tree33d03a5db4eeb1597b5b67316c71980f6e1da169 /test/orm
parent0e4c4d7efc08d04c3c0ae960428b08ada37e4a91 (diff)
downloadsqlalchemy-26ed90ab22dde7bdafe933cb1d16acfe70c1ab78.tar.gz
- Fixed bug where :meth:`.Session.bulk_update_mappings` and related
would not bump a version id counter when in use. The experience here is still a little rough as the original version id is required in the given dictionaries and there's not clean error reporting on that yet. fixes #3610
Diffstat (limited to 'test/orm')
-rw-r--r--test/orm/test_versioning.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/orm/test_versioning.py b/test/orm/test_versioning.py
index 124053d47..07b090c60 100644
--- a/test/orm/test_versioning.py
+++ b/test/orm/test_versioning.py
@@ -130,6 +130,43 @@ class VersioningTest(fixtures.MappedTest):
[(f1.id, 'f1rev2', 2), (f2.id, 'f2rev2', 2)]
)
+ def test_bulk_insert(self):
+ Foo = self.classes.Foo
+
+ s1 = self._fixture()
+ s1.bulk_insert_mappings(
+ Foo,
+ [{"id": 1, "value": "f1"}, {"id": 2, "value": "f2"}]
+ )
+ eq_(
+ s1.query(Foo.id, Foo.value, Foo.version_id).order_by(Foo.id).all(),
+ [(1, 'f1', 1), (2, 'f2', 1)]
+ )
+
+ def test_bulk_update(self):
+ Foo = self.classes.Foo
+
+ s1 = self._fixture()
+ f1 = Foo(value='f1')
+ f2 = Foo(value='f2')
+ s1.add_all((f1, f2))
+ s1.commit()
+
+ s1.bulk_update_mappings(
+ Foo,
+ [
+ {"id": f1.id, "value": "f1rev2", "version_id": 1},
+ {"id": f2.id, "value": "f2rev2", "version_id": 1},
+
+ ]
+ )
+ s1.commit()
+
+ eq_(
+ s1.query(Foo.id, Foo.value, Foo.version_id).order_by(Foo.id).all(),
+ [(f1.id, 'f1rev2', 2), (f2.id, 'f2rev2', 2)]
+ )
+
@testing.emits_warning_on(
'+zxjdbc', r'.*does not support (update|delete)d rowcount')
def test_bump_version(self):