]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Added test on multi-line check constraint extraction on SQLite.
authorJeff Horemans <jeff.horemans@vortex-financials.be>
Wed, 7 Aug 2024 11:09:24 +0000 (13:09 +0200)
committerJeff Horemans <jeff.horemans@vortex-financials.be>
Wed, 7 Aug 2024 11:09:24 +0000 (13:09 +0200)
test/dialect/test_sqlite.py

index 8dedadbde9dc7d9b7c2d249f0dcb8655c6309ef1..10a2736c02901a80eaf873846cf5bea2abe5b686 100644 (file)
@@ -1816,6 +1816,10 @@ class ConstraintReflectionTest(fixtures.TestBase):
 
             Table("q", meta, Column("id", Integer), PrimaryKeyConstraint("id"))
 
+            # intentional new line
+            Table("r", meta, Column("id", Integer), Column("value", Integer), PrimaryKeyConstraint("id"),
+                  CheckConstraint("((value > 0) AND \n(value < 100))"), CheckConstraint("id > 0"))
+
             meta.create_all(conn)
 
             # will contain an "autoindex"
@@ -1911,6 +1915,7 @@ class ConstraintReflectionTest(fixtures.TestBase):
                 "b",
                 "a1",
                 "a2",
+                "r",
             ]:
                 conn.exec_driver_sql("drop table %s" % name)
 
@@ -2506,6 +2511,11 @@ class ConstraintReflectionTest(fixtures.TestBase):
         else:
             assert False
 
+    def test_multiline_check_constraints(self):
+        inspector = inspect(testing.db)
+        constraints = inspector.get_check_constraints('r')
+        eq_(constraints[0]['sqltext'], "((value > 0) AND \n(value < 100))")
+        eq_(constraints[1]['sqltext'], "id > 0")
 
 class SavepointTest(fixtures.TablesTest):
     """test that savepoints work when we use the correct event setup"""