rusackas commented on code in PR #42222:
URL: https://github.com/apache/superset/pull/42222#discussion_r3623678663
##########
superset/connectors/sqla/models.py:
##########
@@ -961,6 +961,7 @@ class TableColumn(AuditMixinNullable, ImportExportMixin,
CertificationMixin, Mod
table: Mapped["SqlaTable"] = relationship(
"SqlaTable",
back_populates="columns",
+ cascade_backrefs=False,
Review Comment:
Went through every `TableColumn(` call site in the codebase looking for a
reverse `column.table = table` assignment onto an already-session-tracked table
with no explicit add. The only real one, `fetch_metadata`, already gets
`db.session.add(new_column)` right above it in this diff. Everything else
either doesn't set `table=` at construction (the ephemeral ones in
`sql_lab.py`) or already adds explicitly before the backref gets set (the v0
import path). Resolving.
##########
tests/integration_tests/sqla_models_tests.py:
##########
@@ -998,18 +1009,20 @@ def test_extra_cache_keys_in_dataset_metrics_and_columns(
mock_username: Mock,
mock_user_id: Mock,
):
+ columns = [
+ TableColumn(column_name="user", type="VARCHAR(255)"),
+ TableColumn(
+ column_name="username",
+ type="VARCHAR(255)",
+ expression="{{ current_username() }}",
+ ),
+ ]
+ db.session.add_all(columns)
table = SqlaTable(
table_name="test_has_no_extra_cache_keys_table",
sql="SELECT 'abc' as user",
database=get_example_database(),
- columns=[
- TableColumn(column_name="user", type="VARCHAR(255)"),
- TableColumn(
- column_name="username",
- type="VARCHAR(255)",
- expression="{{ current_username() }}",
- ),
- ],
+ columns=columns,
Review Comment:
`table_id` is nullable on `TableColumn`, so the autoflush here just inserts
the rows with a null `table_id` instead of raising. No integrity constraint to
violate. CI ran this exact test against postgres, mysql and sqlite and it's
green across all three, so I think Bito's wrong on this one.
--
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]