-
-
Notifications
You must be signed in to change notification settings - Fork 339
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
upgrade 4.1.0 to 4.2.0 cause access to wrong table #522
Comments
can you please check commit history to track it down? |
I am experiencing a similar error in a multidatabase environment. Some relations from non default database with custom routing don't seem to exist. Works on v4.1.0. Haven't had the time to dig in more thoroughly. As @auvipy suggests, I'll try and track the error through the commit history and report back. Thank you! |
Hey there, we are experiencing the same issue when upgrading from 4.1.0 to 4.2.0 and using multiple database. I think the problem comes from the new explaining of queries in this version which uses raw SQL to craft the explain SQL statement. The As stated in the Django documentation, when using raw cursors with multiple databases, you have to manually select the right database to target your SQL query (cf. https://docs.djangoproject.com/en/3.2/topics/db/multi-db/#using-raw-cursors-with-multiple-databases). I don't really know how this can be managed automatically to fix the issue (to find the right db conf based on the query itself), but I'm pretty confident this is the source of the problem for multiple database configuration (as I and @j-zaballa are experiencing) I hope it's enough to help fix the issue @auvipy |
MySQLdb._exceptions.ProgrammingError: (1146, "Table 'olympus.backend_user' doesn't exist") says otherwise |
Hum 🤔 ? It says otherwise about what ? If the wrong database is used (which is the case for the default cursor) then yes in the first DB there is a good chance the table |
I have the same problem with my project that's using multiple databases. As @rafou described, the bug is with the import silk.sql
silk.sql._explain_query = lambda q, param: None I'm happy to work on the issue, will create a PR if I create a sensible fix for it. |
I will be looking forward to a proper PR. |
@caesarleong @rafou @j-zaballa: Please see if #538 fixes the issue for you. |
SQLCompiler has a .connection instance which is already aware of what database it should use. As such, when running EXPLAIN query let's use that connection instead of connection to a default database. Fixes #522.
@glujan thank you so much for the PR. It does indeed solve the issue :) |
Same here, thanks a lot for the fix ! @auvipy would it be possible to release a minor version with the fix please ? 🙏 |
@auvipy Making a minor release for this would be awesome. I have to patch silk in my repo to get it to run tests which is quite annoying |
I am using silk on a system which does not managed the table, its migration model like this
it is work fine on 4.1.0, but I encounter below issue on 4.2.0
it seems something change from 4.1.0 to 4.2.0 at below function
I am not sure what change cause this issue, but I think it should work the same way like 4.1.0 without error.
The text was updated successfully, but these errors were encountered: