-
Notifications
You must be signed in to change notification settings - Fork 14k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(mssql): avoid trying to return a resultset for DML queries with not resultset #24999
fix(mssql): avoid trying to return a resultset for DML queries with not resultset #24999
Conversation
…s empty and there is nothing to return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Yuval-Moshe for the fix. Would you mind looking into why the unit tests are failing? Additionally adding a unit test for this would be greatly appreciated as it would help prevent future regressions if said logic changed. |
…and added and additional test for no cursor description scenario
Hi @john-bodley, sure no problem. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the improvement @Yuval-Moshe!
@michael-s-molina Sure no problem! |
@michael-s-molina Thanks! |
Helm files are maintained by @craig-rueda. I think a Helm release will be available once 3.0 is out. |
SUMMARY
Unlike other db engines, the mssql one does not include a check to see if there is even a need to return a result set before trying to fetch the data, that's why we are failing on a non select queries with the Statement not executed or executed statement has no resultset error.
In order to see if there is any result to try and fetch, we should check if the cursor description is not None.
Just for a reference we can see that other db engines like oracle or postgres do have that check before trying to fetch:
Oracle
https://github.com/apache/superset/blob/85a7d5cb3ebe833cfc2980f0846f15bb7ce1dd01/superset/db_engine_specs/postgres.py#L176C1-L179
Postgres
https://github.com/apache/superset/blob/85a7d5cb3ebe833cfc2980f0846f15bb7ce1dd01/superset/db_engine_specs/postgres.py#L176C1-L179
The result is failure in running a DML queries due to 'mssql error: Statement not executed or executed statement has no resultset'
So the fix is simply to add that check before calling the inherited fetch_data method.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
Run a DML query via the SQL Lab on an mssql DB
ADDITIONAL INFORMATION