From 377f12696bb1af17bb14f676a49ef21428d537d3 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 24 Jan 2019 16:56:44 -0500 Subject: 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 --- test/dialect/postgresql/test_reflection.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/dialect/postgresql/test_reflection.py') 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): -- cgit v1.2.1