summaryrefslogtreecommitdiff
path: root/test/dialect/test_sqlite.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-05-01 22:22:51 +0200
committerFederico Caselli <cfederico87@gmail.com>2020-05-19 19:33:02 +0200
commit87949deb04068868e941bb99947c70e78c4afc8a (patch)
tree5e64b5e15abe0fde3c1d0c5240b758d0f2c50efa /test/dialect/test_sqlite.py
parent53af60b3536221f2503af29c1e90cf9db1295faf (diff)
downloadsqlalchemy-87949deb04068868e941bb99947c70e78c4afc8a.tar.gz
SQLite 3.31 added support for computed column.
This change enables their support in SQLAlchemy when targeting SQLite. Fixes: #5297 Change-Id: Ia9f21a49e58fc977e3c669b8176036c95d93b9c8
Diffstat (limited to 'test/dialect/test_sqlite.py')
-rw-r--r--test/dialect/test_sqlite.py29
1 files changed, 16 insertions, 13 deletions
diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py
index 1fffd5953..04a15d587 100644
--- a/test/dialect/test_sqlite.py
+++ b/test/dialect/test_sqlite.py
@@ -600,11 +600,15 @@ class DefaultsTest(fixtures.TestBase, AssertsCompiledSQL):
"""test non-quoted integer value on older sqlite pragma"""
dialect = sqlite.dialect()
- info = dialect._get_column_info("foo", "INTEGER", False, 3, False)
+ info = dialect._get_column_info(
+ "foo", "INTEGER", False, 3, False, False, False, None
+ )
eq_(info["default"], "3")
-class DialectTest(fixtures.TestBase, AssertsExecutionResults):
+class DialectTest(
+ fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL
+):
__only_on__ = "sqlite"
@@ -779,13 +783,13 @@ class DialectTest(fixtures.TestBase, AssertsExecutionResults):
eq_(d.create_connect_args(url), expected)
@testing.combinations(
- ("no_persisted", "ignore"),
- ("persisted_none", None),
- ("persisted_true", True),
- ("persisted_false", False),
- id_="ia",
+ ("no_persisted", "", "ignore"),
+ ("persisted_none", "", None),
+ ("persisted_true", " STORED", True),
+ ("persisted_false", " VIRTUAL", False),
+ id_="iaa",
)
- def test_column_computed(self, persisted):
+ def test_column_computed(self, text, persisted):
m = MetaData()
kwargs = {"persisted": persisted} if persisted != "ignore" else {}
t = Table(
@@ -794,11 +798,10 @@ class DialectTest(fixtures.TestBase, AssertsExecutionResults):
Column("x", Integer),
Column("y", Integer, Computed("x + 2", **kwargs)),
)
- assert_raises_message(
- exc.CompileError,
- "SQLite does not support computed columns",
- schema.CreateTable(t).compile,
- dialect=sqlite.dialect(),
+ self.assert_compile(
+ schema.CreateTable(t),
+ "CREATE TABLE t (x INTEGER,"
+ " y INTEGER GENERATED ALWAYS AS (x + 2)%s)" % text,
)