diff options
author | tsauerwein <tobias.sauerwein@camptocamp.com> | 2016-02-20 17:20:50 +0100 |
---|---|---|
committer | tsauerwein <tobias.sauerwein@camptocamp.com> | 2016-02-20 17:20:50 +0100 |
commit | 1b60340c63c84aa478988a285450fa4d5e2f7bd0 (patch) | |
tree | b8eafca87cf55c2fd307759d7c0e7ea1093762d7 /test/orm/test_bulk.py | |
parent | 60a9d2da25da68466130771afc3f35c9473aca02 (diff) | |
download | sqlalchemy-pr/243.tar.gz |
Add argument 'with_none' to Session.bulk_insert_mappingspr/243
Diffstat (limited to 'test/orm/test_bulk.py')
-rw-r--r-- | test/orm/test_bulk.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/test/orm/test_bulk.py b/test/orm/test_bulk.py index 878560cf6..4e1f9a592 100644 --- a/test/orm/test_bulk.py +++ b/test/orm/test_bulk.py @@ -17,11 +17,12 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest): @classmethod def setup_mappers(cls): - User, Address = cls.classes("User", "Address") - u, a = cls.tables("users", "addresses") + User, Address, Order = cls.classes("User", "Address", "Order") + u, a, o = cls.tables("users", "addresses", "orders") mapper(User, u) mapper(Address, a) + mapper(Order, o) def test_bulk_save_return_defaults(self): User, = self.classes("User",) @@ -155,6 +156,28 @@ class BulkInsertUpdateTest(BulkTest, _fixtures.FixtureTest): ) ) + def test_bulk_insert_with_none(self): + Order, = self.classes("Order",) + + s = Session() + with self.sql_execution_asserter() as asserter: + s.bulk_insert_mappings( + Order, + [{'id': 1, 'description': 'u1new'}, + {'id': 2, 'description': None}, + {'id': 3, 'description': 'u3new'}], + with_none=True + ) + + asserter.assert_( + CompiledSQL( + "INSERT INTO orders (id, description) VALUES (:id, :description)", + [{'id': 1, 'description': 'u1new'}, + {'id': 2, 'description': None}, + {'id': 3, 'description': 'u3new'}] + ) + ) + class BulkUDPostfetchTest(BulkTest, fixtures.MappedTest): @classmethod |