diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-13 10:52:00 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-04-14 12:51:58 -0400 |
| commit | 94a1c523984e2082bb16d784cf8615061ba9d49a (patch) | |
| tree | 73892187edabbfa4a371631c3407510cfdea9313 /test/sql | |
| parent | de7f14104d5278987fa72d6866fa39569e56077e (diff) | |
| download | sqlalchemy-94a1c523984e2082bb16d784cf8615061ba9d49a.tar.gz | |
Support DEFAULT VALUES and VALUES(DEFAULT) individually
Fixed regression where the introduction of the INSERT syntax "INSERT...
VALUES (DEFAULT)" was not supported on some backends that do however
support "INSERT..DEFAULT VALUES", including SQLite. The two syntaxes are
now each individually supported or non-supported for each dialect, for
example MySQL supports "VALUES (DEFAULT)" but not "DEFAULT VALUES".
Support for Oracle is still not enabled as there are unresolved issues
in using RETURNING at the same time.
Fixes: #6254
Change-Id: I47959bc826e3d9d2396ccfa290eb084841b02e77
Diffstat (limited to 'test/sql')
| -rw-r--r-- | test/sql/test_defaults.py | 26 | ||||
| -rw-r--r-- | test/sql/test_insert.py | 12 |
2 files changed, 16 insertions, 22 deletions
diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index 543ae1f98..007dc157b 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -2,7 +2,6 @@ import datetime import itertools import sqlalchemy as sa -from sqlalchemy import Boolean from sqlalchemy import cast from sqlalchemy import DateTime from sqlalchemy import exc @@ -1062,25 +1061,6 @@ class PKIncrementTest(fixtures.TablesTest): ) -class EmptyInsertTest(fixtures.TestBase): - __backend__ = True - - @testing.fails_on("oracle", "FIXME: unknown") - def test_empty_insert(self, metadata, connection): - t1 = Table( - "t1", - metadata, - Column("is_true", Boolean, server_default=("1")), - ) - metadata.create_all(connection) - connection.execute(t1.insert()) - eq_( - 1, - connection.scalar(select(func.count(text("*"))).select_from(t1)), - ) - eq_(True, connection.scalar(t1.select())) - - class AutoIncrementTest(fixtures.TestBase): __backend__ = True @@ -1088,7 +1068,11 @@ class AutoIncrementTest(fixtures.TestBase): @testing.requires.empty_inserts def test_autoincrement_single_col(self, metadata, connection): single = Table( - "single", self.metadata, Column("id", Integer, primary_key=True) + "single", + self.metadata, + Column( + "id", Integer, primary_key=True, test_needs_autoincrement=True + ), ) self.metadata.create_all(connection) diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py index a128db8a9..95a8d02a2 100644 --- a/test/sql/test_insert.py +++ b/test/sql/test_insert.py @@ -951,7 +951,9 @@ class EmptyTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): table1 = self.tables.mytable dialect = default.DefaultDialect() - dialect.supports_empty_insert = dialect.supports_default_values = True + dialect.supports_empty_insert = False + dialect.supports_default_values = True + dialect.supports_default_metavalue = True stmt = table1.insert().values({}) self.assert_compile( @@ -961,6 +963,14 @@ class EmptyTest(_InsertTestBase, fixtures.TablesTest, AssertsCompiledSQL): for_executemany=True, ) + dialect.supports_default_metavalue = False + self.assert_compile( + stmt, + "INSERT INTO mytable DEFAULT VALUES", + dialect=dialect, + for_executemany=True, + ) + def test_supports_empty_insert_false(self): table1 = self.tables.mytable |
