rusackas opened a new pull request, #42944:
URL: https://github.com/apache/superset/pull/42944
Follow-up to #40397. That PR added generic m2m relationship filtering to
`BaseDAO.apply_column_operators`/`_apply_relationship_filter`, including
`eq`/`ne`/`in`/`nin`/`is_null`/`is_not_null` support for columns like
`dashboards` on `list_charts`.
### SUMMARY
`_apply_relationship_filter`'s `ne` branch built `~column.any(related_pk ==
value)` without checking that `value` is a scalar. Passing a list (e.g. `{col:
"dashboards", opr: "ne", value: [1, 2]}`) silently compiled to `related_pk ==
[1, 2]`, which produces unpredictable cross-backend behavior instead of a clear
error. This adds a scalar-value guard to the `ne` branch, matching the intent
of the rest of the operator dispatch (fail loudly with a clear message rather
than pass a malformed comparison to SQLAlchemy).
### BEFORE/AFTER
**Before:**
```
{col: "dashboards", opr: "ne", value: [1, 2]}
→ compiles to `related_pk == [1, 2]`, backend-dependent behavior
```
**After:**
```
{col: "dashboards", opr: "ne", value: [1, 2]}
→ ValueError: Operator 'ne' on relationship column 'dashboards' requires
a scalar value, got list. Use 'nin' to exclude multiple related ids.
```
### TESTING INSTRUCTIONS
```bash
pytest tests/unit_tests/daos/test_base_relationship_filters.py
```
Added `test_ne_on_relationship_dispatches_to_any` (scalar `ne` still works)
and `test_ne_on_relationship_rejects_list_value` (list `ne` raises
`ValueError`). Adjusted `test_supported_relationship_operators_dispatch` to no
longer pass a list value for `ne` since that's now invalid.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [x] Introduces new feature or API: no, tightens validation on an existing
filter path
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]