rusackas commented on code in PR #43499:
URL: https://github.com/apache/superset/pull/43499#discussion_r3850145851
##########
superset/models/sql_lab.py:
##########
@@ -551,6 +551,15 @@ def to_dict(self) -> dict[str, Any]:
"id": self.id,
}
+ @property
+ def name(self) -> str:
+ """
+ Expose ``label`` as ``name`` so callers that treat a ``SavedQuery`` as
+ a generic datasource (e.g. chart create/update commands) can rely on
+ a uniform ``name`` attribute across all datasource types.
+ """
+ return self.label
Review Comment:
Good catch, fixed. `label` is nullable so `name` (and `perm`, which now uses
it too) fall back to an id-based name instead of returning `None`.
##########
superset/models/sql_lab.py:
##########
@@ -551,6 +551,15 @@ def to_dict(self) -> dict[str, Any]:
"id": self.id,
}
+ @property
+ def name(self) -> str:
+ """
+ Expose ``label`` as ``name`` so callers that treat a ``SavedQuery`` as
+ a generic datasource (e.g. chart create/update commands) can rely on
+ a uniform ``name`` attribute across all datasource types.
+ """
+ return self.label
Review Comment:
You're right, fixed. Added perm/schema_perm/catalog_perm to SavedQuery and a
test that calls raise_for_access for real instead of mocking it, so it actually
exercises the non-admin branch you're describing.
##########
superset/models/sql_lab.py:
##########
@@ -551,6 +551,15 @@ def to_dict(self) -> dict[str, Any]:
"id": self.id,
}
+ @property
+ def name(self) -> str:
+ """
+ Expose ``label`` as ``name`` so callers that treat a ``SavedQuery`` as
+ a generic datasource (e.g. chart create/update commands) can rely on
+ a uniform ``name`` attribute across all datasource types.
+ """
+ return self.label
Review Comment:
Same fix covers this, set_related_perm reads those same three attributes.
Added a test that calls it directly against a saved_query-backed Slice to pin
it down.
--
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]