mikebridge commented on code in PR #40130:
URL: https://github.com/apache/superset/pull/40130#discussion_r3365147174
##########
tests/integration_tests/dashboard_utils.py:
##########
@@ -35,10 +36,23 @@ def get_table(
schema: Optional[str] = None,
):
schema = schema or get_example_default_schema()
+ # Bypass the soft-delete listener so the helper finds rows previously
+ # soft-deleted by other tests in the same session. Without the
+ # bypass, the listener hides them and a subsequent INSERT collides
+ # with the underlying ``(database_id, catalog, schema, table_name)``
+ # unique constraint that survives soft-delete. Prefer live rows over
+ # soft-deleted ones via ``ORDER BY deleted_at IS NULL DESC, id`` —
+ # the filter doesn't include ``catalog``, so it can match more than
+ # one row when a soft-deleted row coexists with a live row that
+ # differs only by catalog (e.g. NULL vs ``"public"``). ``.first()``
+ # plus the live-first ordering keeps the behaviour predictable
+ # without surfacing a ``MultipleResultsFound`` for that case.
return (
db.session.query(SqlaTable)
+ .execution_options(**{SKIP_VISIBILITY_FILTER_CLASSES: {SqlaTable}})
.filter_by(database_id=database.id, schema=schema,
table_name=table_name)
- .one_or_none()
+ .order_by(SqlaTable.deleted_at.is_(None).desc(), SqlaTable.id)
+ .first()
Review Comment:
Fixed in d66d661b36 — `get_table` now includes the normalized `catalog`
(database default, the same rule `validate_uniqueness` applies) in the lookup,
so it can't bind to a different catalog variant when rows share `(database_id,
schema, table_name)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]