From 3aeb30ea104ca6cbe6972f7ec64233cadbaccd82 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Thu, 5 Jan 2023 10:34:37 -0500 Subject: warn and skip for FKs that refer to invisible cols for Oracle Supported use case for foreign key constraints where the local column is marked as "invisible". The errors normally generated when a :class:`.ForeignKeyConstraint` is created that check for the target column are disabled when reflecting, and the constraint is skipped with a warning in the same way which already occurs for an :class:`.Index` with a similar issue. tests are added for indexes, unique constraints, and primary key constraints, which were already working; indexes and uniques warn, primary keys don't which we would assume is because we never see those PK columns in the first place. Constraints now raise an informative ConstraintColumnNotFoundError in the general case for strings in the "pending colargs" collection not being resolvable. Fixes: #9059 Change-Id: I400cf0bff6abba0e0c75f38b07617be1a8ec3453 --- test/sql/test_metadata.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'test/sql') diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index 56bb89541..7f6bee72b 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -3946,11 +3946,12 @@ class ConstraintTest(fixtures.TestBase): def test_raise_index_nonexistent_name(self): m = MetaData() - # the KeyError isn't ideal here, a nicer message - # perhaps - assert_raises( - KeyError, Table, "t", m, Column("x", Integer), Index("foo", "q") - ) + + with expect_raises_message( + exc.ConstraintColumnNotFoundError, + "Can't create Index on table 't': no column named 'q' is present.", + ): + Table("t", m, Column("x", Integer), Index("foo", "q")) def test_raise_not_a_column(self): assert_raises(exc.ArgumentError, Index, "foo", 5) -- cgit v1.2.1