summaryrefslogtreecommitdiff
path: root/test/dialect/test_sqlite.py
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2016-04-11 17:01:42 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2016-06-01 12:57:36 -0400
commita8e7bb8782ca8fd858ac036082104b4ac2991cfc (patch)
treec3b2a3c1e68b364e33feacd91221b405c6ad737f /test/dialect/test_sqlite.py
parent3f55039e7f15efafacc3e8e0fbf0ba38fa612b09 (diff)
downloadsqlalchemy-a8e7bb8782ca8fd858ac036082104b4ac2991cfc.tar.gz
Implemented CHECK constraint reflection for SQLite and PostgreSQL
Co-Authored-By: Mike Bayer <mike_mp@zzzcomputing.com> Change-Id: Ie6cf2d2958d1c567324db9e08fef2d3186e97350 Pull-request: https://bitbucket.org/zzzeek/sqlalchemy/pull-requests/80
Diffstat (limited to 'test/dialect/test_sqlite.py')
-rw-r--r--test/dialect/test_sqlite.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py
index 580950b12..dde9da086 100644
--- a/test/dialect/test_sqlite.py
+++ b/test/dialect/test_sqlite.py
@@ -1147,6 +1147,13 @@ class ConstraintReflectionTest(fixtures.TestBase):
# will contain an "autoindex"
conn.execute("create table o (foo varchar(20) primary key)")
+ conn.execute(
+ "CREATE TABLE cp ("
+ "q INTEGER check (q > 1 AND q < 6),\n"
+ "CONSTRAINT cq CHECK (q == 1 OR (q > 2 AND q < 5))\n"
+ ")"
+ )
+
@classmethod
def teardown_class(cls):
with testing.db.begin() as conn:
@@ -1373,6 +1380,14 @@ class ConstraintReflectionTest(fixtures.TestBase):
{'constrained_columns': [], 'name': None}
)
+ def test_check_constraint(self):
+ inspector = Inspector(testing.db)
+ eq_(
+ inspector.get_check_constraints("cp"),
+ [{'sqltext': 'q > 1 AND q < 6', 'name': None},
+ {'sqltext': 'q == 1 OR (q > 2 AND q < 5)', 'name': 'cq'}]
+ )
+
class SavepointTest(fixtures.TablesTest):