Commit ac8ec49
fix(datasets): bypass soft-delete in dashboard_utils.get_table for tests
CI test-postgres (current) on PR apache#40130 cascade-failed with:
psycopg2.errors.UniqueViolation: duplicate key value violates unique
constraint "_customer_location_uc"
DETAIL: Key (database_id, schema, table_name)=(1, public, birth_names)
already exists.
Root cause: dashboard_utils.get_table queries SqlaTable through the
ORM, which the soft-delete listener now filters. When a prior test in
the same session soft-deletes the birth_names row (any test exercising
the new soft-delete DELETE behavior on datasets), the row stays in the
DB but is hidden from the helper. create_table_metadata's "doesn't
exist, INSERT" path then collides with the underlying (database_id,
schema, table_name) unique constraint that survives soft-delete (the
constraint is enforced even though the SQLAlchemy comment claims it's
not physical — Postgres test environments enforce it via a named
constraint that an old migration tried to drop).
Two-part fix in tests/integration_tests/dashboard_utils.py:
1. get_table attaches a per-query SKIP_VISIBILITY_FILTER_CLASSES
execution option so it sees soft-deleted leftovers. Scoped to the
single query — no leak to anything else in the session.
2. create_table_metadata restores any soft-deleted row it finds before
mutating it for the new test's setup. Without this, the test would
succeed in finding the row but then operate on a row whose
`deleted_at` is still set, which the listener would hide from any
subsequent API queries inside the same test.
Mirrors the pattern the dashboards branch (sc-106190) uses for
insert_dashboard's defensive cleanup, scoped narrowly to the test
helper and limited to SqlaTable.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bf87b03 commit ac8ec49
1 file changed
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
35 | 36 | | |
36 | 37 | | |
37 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
38 | 44 | | |
39 | 45 | | |
| 46 | + | |
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
| |||
60 | 67 | | |
61 | 68 | | |
62 | 69 | | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
63 | 76 | | |
64 | 77 | | |
65 | 78 | | |
| |||
0 commit comments