-
Notifications
You must be signed in to change notification settings - Fork 116
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
Query results different on 1.5 on static query. #394
Comments
Thanks for the report. If you manage to get some repro steps, that would be great. |
I have the same issue, running MyModel.objects.raw("some sql with a LIKE here") returns different results when run in the ORM vs when I run it in SQL Server Management Studio. I'm trying to make a demo, but when I dumb the query down a bit it works properly. For reference, our original query with the issue has CTE's, subqueries etc, with the problematic "LIKE" being in an outer apply. |
My initial attempts to recreate with simple LIKEs with CTEs have not resulted in reproducing this bug. So unsurprisingly seems like a more subtle bug. |
So we worked out the issue on our end, when we updated to 1.5, one of our raw queries had |
We did make some changes in 1.5 that would affect those queries. Thanks for figuring it out, will fix this in the next release. |
There are some features which are not supported yet. Please check the Limitations first to see if your bug is listed.
Software versions
Table schema and Model
I don't know how much I can share and haven't been able to narrow down exactly to an easy demo. Will report back if I can, but wanted to just simply flag that something changed.
Database Connection Settings
Problem description and steps to reproduce
Again I know this is a kind of useless report as I don't know how much I can share about our query and schema, but mostly just putting on your radar. Feel free to close as unhelpful.
We have an ETL that runs and reads from a DB that is not managed by django, we have a prepared query we read from a flat file and execute with a cursor directly as part of a very simple ETL from a legacy system. After updating to 1.5, the query results changed to have fewer results (1.1M rows). The query has no templating/rendering, it is just running a set SQL statement. On 1.4.2 we get approximately 1.4M rows, this agrees with the results when running on SQL Management Studio directly (and dbeaver with
Microsoft JDBC Driver for SQL Server
driver, unknown version).The query uses a couple of CTEs, lots of CASE statements, joins, LIKE comparisons, and other standard comparisons (
IS NULL
,IN
list) but nothing too exotic that should be pushing the bounds.Expected behavior and actual behavior
After updating to 1.5 I would expect that a query result would not change and would agree with all other database tools.
Error message/stack trace
Any other details that can be helpful
I had django log the exact query it was using, there was no change to rendering, etc (as expected).
I wish I could be more helpful. I'll see if I can reproduce in a small demo setup and identify exactly what the issue was. But since the update appears to be silently modifying the results of queries, I wanted to flag in case other users have similar results.
The text was updated successfully, but these errors were encountered: