diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-09-08 21:34:39 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-09-08 21:41:13 -0400 |
| commit | 70be7312f10a2241cde3e6472af15ef5a9ae222a (patch) | |
| tree | 7e7e28baf1a5fc7d2d07c6249b2b177abe770ef8 /test/dialect | |
| parent | 5ae984b946f87cc485c29c4c947a8649d4c4c422 (diff) | |
| download | sqlalchemy-70be7312f10a2241cde3e6472af15ef5a9ae222a.tar.gz | |
Rename MySQL dml.insert().values to .inserted
Changed the name of the ``.values`` attribute of the new MySQL
INSERT..ON DUPLICATE KEY UPDATE construct to ``.inserted``, as
:class:`.Insert` already has a method called :meth:`.Insert.values`.
The ``.inserted`` attribute ultimately renders the MySQL ``VALUES()``
function.
Change-Id: I8da8e30a3077698385a4b77e2c2032e2d1ff10b2
Fixes: #4072
Diffstat (limited to 'test/dialect')
| -rw-r--r-- | test/dialect/mysql/test_compiler.py | 14 | ||||
| -rw-r--r-- | test/dialect/mysql/test_on_duplicate.py | 13 |
2 files changed, 14 insertions, 13 deletions
diff --git a/test/dialect/mysql/test_compiler.py b/test/dialect/mysql/test_compiler.py index 3663a4800..e8731e532 100644 --- a/test/dialect/mysql/test_compiler.py +++ b/test/dialect/mysql/test_compiler.py @@ -704,10 +704,10 @@ class InsertOnDuplicateTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_from_values(self): - stmt = insert( - self.table, [{'id': 1, 'bar': 'ab'}, {'id': 2, 'bar': 'b'}]) + stmt = insert(self.table).values( + [{'id': 1, 'bar': 'ab'}, {'id': 2, 'bar': 'b'}]) stmt = stmt.on_duplicate_key_update( - bar=stmt.values.bar, baz=stmt.values.baz) + bar=stmt.inserted.bar, baz=stmt.inserted.baz) expected_sql = ( 'INSERT INTO foos (id, bar) VALUES (%s, %s), (%s, %s) ' 'ON DUPLICATE KEY UPDATE bar = VALUES(bar), baz = VALUES(baz)' @@ -715,8 +715,8 @@ class InsertOnDuplicateTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile(stmt, expected_sql) def test_from_literal(self): - stmt = insert( - self.table, [{'id': 1, 'bar': 'ab'}, {'id': 2, 'bar': 'b'}]) + stmt = insert(self.table).values( + [{'id': 1, 'bar': 'ab'}, {'id': 2, 'bar': 'b'}]) stmt = stmt.on_duplicate_key_update(bar=literal_column('bb')) expected_sql = ( 'INSERT INTO foos (id, bar) VALUES (%s, %s), (%s, %s) ' @@ -725,8 +725,8 @@ class InsertOnDuplicateTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile(stmt, expected_sql) def test_python_values(self): - stmt = insert( - self.table, [{'id': 1, 'bar': 'ab'}, {'id': 2, 'bar': 'b'}]) + stmt = insert(self.table).values( + [{'id': 1, 'bar': 'ab'}, {'id': 2, 'bar': 'b'}]) stmt = stmt.on_duplicate_key_update(bar="foobar") expected_sql = ( 'INSERT INTO foos (id, bar) VALUES (%s, %s), (%s, %s) ' diff --git a/test/dialect/mysql/test_on_duplicate.py b/test/dialect/mysql/test_on_duplicate.py index 2ff4a58cc..9a026f9ed 100644 --- a/test/dialect/mysql/test_on_duplicate.py +++ b/test/dialect/mysql/test_on_duplicate.py @@ -29,8 +29,9 @@ class OnDuplicateTest(fixtures.TablesTest): foos = self.tables.foos with testing.db.connect() as conn: conn.execute(insert(foos, dict(id=1, bar='b', baz='bz'))) - stmt = insert(foos, [dict(id=1, bar='ab'), dict(id=2, bar='b')]) - stmt = stmt.on_duplicate_key_update(bar=stmt.values.bar) + stmt = insert(foos).values( + [dict(id=1, bar='ab'), dict(id=2, bar='b')]) + stmt = stmt.on_duplicate_key_update(bar=stmt.inserted.bar) result = conn.execute(stmt) eq_(result.inserted_primary_key, [2]) eq_( @@ -41,17 +42,17 @@ class OnDuplicateTest(fixtures.TablesTest): def test_last_inserted_id(self): foos = self.tables.foos with testing.db.connect() as conn: - stmt = insert(foos, {"bar": "b", "baz": "bz"}) + stmt = insert(foos).values({"bar": "b", "baz": "bz"}) result = conn.execute( stmt.on_duplicate_key_update( - bar=stmt.values.bar, baz="newbz") + bar=stmt.inserted.bar, baz="newbz") ) eq_(result.inserted_primary_key, [1]) - stmt = insert(foos, {"id": 1, "bar": "b", "baz": "bz"}) + stmt = insert(foos).values({"id": 1, "bar": "b", "baz": "bz"}) result = conn.execute( stmt.on_duplicate_key_update( - bar=stmt.values.bar, baz="newbz") + bar=stmt.inserted.bar, baz="newbz") ) eq_(result.inserted_primary_key, [1]) |
