summaryrefslogtreecommitdiff
path: root/test/dialect/postgresql/test_reflection.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-01-24 16:56:44 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-01-24 19:25:59 -0500
commit377f12696bb1af17bb14f676a49ef21428d537d3 (patch)
tree6404ec58d222434282b577b992c88928db3ae9c1 /test/dialect/postgresql/test_reflection.py
parent99b7dd4512364f1f1f11212fd87355ea098a93a6 (diff)
downloadsqlalchemy-377f12696bb1af17bb14f676a49ef21428d537d3.tar.gz
Use pg_get_constraintdef for CHECK constraint reflection
Revised the query used when reflecting CHECK constraints to make use of the ``pg_get_constraintdef`` function, as the ``consrc`` column is being deprecated in PG 12. Thanks to John A Stevenson for the tip. Fixes: #4463 Change-Id: Ie0ee9bdfddb0635db72b35c2e2e4b27f154162fd
Diffstat (limited to 'test/dialect/postgresql/test_reflection.py')
-rw-r--r--test/dialect/postgresql/test_reflection.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py
index 311835dae..ae1dff6d0 100644
--- a/test/dialect/postgresql/test_reflection.py
+++ b/test/dialect/postgresql/test_reflection.py
@@ -28,6 +28,7 @@ from sqlalchemy.dialects.postgresql import TSRANGE
from sqlalchemy.engine import reflection
from sqlalchemy.sql.schema import CheckConstraint
from sqlalchemy.testing import fixtures
+from sqlalchemy.testing import mock
from sqlalchemy.testing.assertions import assert_raises
from sqlalchemy.testing.assertions import AssertsExecutionResults
from sqlalchemy.testing.assertions import eq_
@@ -1424,6 +1425,20 @@ class ReflectionTest(fixtures.TestBase):
},
)
+ def test_reflect_check_warning(self):
+ conn = mock.Mock(
+ execute=lambda *arg, **kw: mock.Mock(
+ fetchall=lambda: [("some name", "NOTCHECK foobar")]
+ )
+ )
+ with mock.patch.object(
+ testing.db.dialect, "get_table_oid", lambda *arg, **kw: 1
+ ):
+ with testing.expect_warnings(
+ "Could not parse CHECK constraint text: 'NOTCHECK foobar'"
+ ):
+ testing.db.dialect.get_check_constraints(conn, "foo")
+
class CustomTypeReflectionTest(fixtures.TestBase):
class CustomType(object):