john-bodley commented on code in PR #24301:
URL: https://github.com/apache/superset/pull/24301#discussion_r1232888725
##########
superset/queries/saved_queries/dao.py:
##########
@@ -44,3 +47,20 @@ def bulk_delete(models: Optional[list[SavedQuery]], commit:
bool = True) -> None
except SQLAlchemyError as ex:
db.session.rollback()
raise DAODeleteFailedError() from ex
+
+ @classmethod
+ def get_by_id(cls, _id: str) -> Optional[SavedQuery]:
Review Comment:
@zephyring, @jfrag1, @eschutho, et al. I'm supportive of "reverting" the
original PR to get us back to square one and then with said SIP we can proceed.
I suspect the old API endpoint is a legacy [FAB REST
API](https://flask-appbuilder.readthedocs.io/en/latest/quickhowto.html#rest-api)
which was slated for deletion in 2.3.X (we're now using FAB 4.3.2+).
If the one line revert to the old API isn't via I think the alternative is
something akin to what we do at Airbnb, where our PR description states:
> Though this logic,
>
>
> ```python
> class SavedQueryFilter(BaseFilter): # pylint:
disable=too-few-public-methods
> def apply(self, query: BaseQuery, value: Any) -> BaseQuery:
> """
> Filter saved queries to only those created by current user.
>
> :returns: flask-sqlalchemy query
> """
>
> return query.filter(
> SavedQuery.created_by == g.user # pylint:
disable=comparison-with-callable
> )
>```
>which, restricts only the creator of the saved query to access it, has been
around for [years](https://github.com/apache/superset/pull/10793) we suspect it
only came into force when the /api/v1/saved_query/{pk} API was enabled in Q4 of
2022 which prevented people from sharing saved queries.
>
> This PR simply relaxes the filter to allow anyone to access a saved query.
Thus I _think_ an alternative to changing the API endpoint would be to
simply replace [these
lines](https://github.com/apache/superset/blob/884a8b52d6a8535ae54c7dab3bfcad3388658877/superset/queries/saved_queries/filters.py#L78-L80)
with `return query`.
##########
superset/queries/saved_queries/dao.py:
##########
@@ -44,3 +47,20 @@ def bulk_delete(models: Optional[list[SavedQuery]], commit:
bool = True) -> None
except SQLAlchemyError as ex:
db.session.rollback()
raise DAODeleteFailedError() from ex
+
+ @classmethod
+ def get_by_id(cls, _id: str) -> Optional[SavedQuery]:
Review Comment:
@zephyring, @jfrag1, @eschutho, @michael-s-molina, et al. I'm supportive of
"reverting" the original PR to get us back to square one and then with said SIP
we can proceed. I suspect the old API endpoint is a legacy [FAB REST
API](https://flask-appbuilder.readthedocs.io/en/latest/quickhowto.html#rest-api)
which was slated for deletion in 2.3.X (we're now using FAB 4.3.2+).
If the one line revert to the old API isn't via I think the alternative is
something akin to what we do at Airbnb, where our PR description states:
> Though this logic,
>
>
> ```python
> class SavedQueryFilter(BaseFilter): # pylint:
disable=too-few-public-methods
> def apply(self, query: BaseQuery, value: Any) -> BaseQuery:
> """
> Filter saved queries to only those created by current user.
>
> :returns: flask-sqlalchemy query
> """
>
> return query.filter(
> SavedQuery.created_by == g.user # pylint:
disable=comparison-with-callable
> )
>```
>which, restricts only the creator of the saved query to access it, has been
around for [years](https://github.com/apache/superset/pull/10793) we suspect it
only came into force when the /api/v1/saved_query/{pk} API was enabled in Q4 of
2022 which prevented people from sharing saved queries.
>
> This PR simply relaxes the filter to allow anyone to access a saved query.
Thus I _think_ an alternative to changing the API endpoint would be to
simply replace [these
lines](https://github.com/apache/superset/blob/884a8b52d6a8535ae54c7dab3bfcad3388658877/superset/queries/saved_queries/filters.py#L78-L80)
with `return query`.
--
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]