EnxDev commented on code in PR #42472:
URL: https://github.com/apache/superset/pull/42472#discussion_r3673701283
##########
superset/views/base_api.py:
##########
@@ -501,8 +501,15 @@ def _add_extra_ids_to_result(
values = [row["value"] for row in result]
ids = [id_ for id_ in ids if id_ not in values]
pk_col = datamodel.get_pk()
- # Fetch requested values from ids
- extra_rows =
db.session.query(datamodel.obj).filter(pk_col.in_(ids)).all()
+ # Fetch requested values from ids, applying the same scoping as the
+ # unforced query so ``include_ids`` cannot resolve rows the
+ # related-field filters deliberately hide.
+ query = db.session.query(datamodel.obj).filter(pk_col.in_(ids))
+ if base_filters :=
self.base_related_field_filters.get(column_name):
+ query = datamodel.apply_filters(
+ query,
datamodel.get_filters().add_filter_list(base_filters)
+ )
Review Comment:
Filters.add_filter_list returns self, not None — FAB's implementation ends
with return self (flask_appbuilder/models/filters.py:241). So
datamodel.get_filters().add_filter_list(base_filters) passes a Filters instance
to apply_filters, and the forced-ID scoping works;
tests/unit_tests/views/test_related_include_ids.py exercises exactly this path.
No change needed.
--
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]