rusackas opened a new pull request, #43499:
URL: https://github.com/apache/superset/pull/43499

   ### SUMMARY
   Creating (or updating) a chart with `datasource_type: saved_query` raised a 
fatal `'SavedQuery' object has no attribute 'name'` error. 
`CreateChartCommand`/`UpdateChartCommand.validate()` read `datasource.name` to 
populate `datasource_name`, and every other datasource type (`SqlaTable`, 
`Query`, `SemanticView`) exposes a `name`, but `SavedQuery` only had a `label` 
column. This adds a `name` property to `SavedQuery` that returns `label`, so it 
behaves like the rest of the `Datasource` union instead of special-casing the 
command layer.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A (backend-only fix, no UI change)
   
   ### TESTING INSTRUCTIONS
   - Added a regression test that pins the bug: 
`tests/unit_tests/commands/chart/test_access_checks.py::test_create_chart_command_supports_saved_query_datasource`
 builds a real `SavedQuery` (not a mock) and asserts 
`CreateChartCommand.validate()` no longer raises `AttributeError` and correctly 
derives `datasource_name` from `label`.
   - Manually: `POST /api/v1/chart/` with `datasource_type: "saved_query"` and 
a valid `datasource_id` should now create the chart instead of returning a 500.
   - `pytest tests/unit_tests/commands/chart/test_access_checks.py 
tests/unit_tests/models/sql_lab_test.py`
   
   ### ADDITIONAL INFORMATION
   - [x] Has associated issue: Fixes #29697
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
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]

Reply via email to