Fixed #10070 -- Added support for pyformat style parameters on SQLite.#16243
Fixed #10070 -- Added support for pyformat style parameters on SQLite.#16243felixxm merged 1 commit intodjango:mainfrom
Conversation
|
Looks like some tests for |
It works, but the same is needed for |
|
@charettes @felixxm I’m not sure why the tests are failing here. When I run it locally the tests pass (macOS 12.6 Monterey virtual environment with Python 3.10.2) so I’m kind of at a loss as to what to do ( I did forget to run the linters on my code locally but have done that now …. but I don’t want to push up another change until I can try and figure out why the tests aren’t passing in CI) Also, the code as submitted work (locally at least) but I think it can be refactored though I’m not really sure how. Any input you have on it would be welcome! |
|
@ryancheley the postgres test failure is a fluke that isn't related to your changes. It's safe to ignore it and focus on the linting failures. |
ngnpope
left a comment
There was a problem hiding this comment.
There are a couple of issues with the approach:
- There is duplication which should be pushed down into
.convert_query(). - Converting
%(value)sto:valuein this way will also convert%%sto%swhich will then be incorrectly converted to?in.convert_query(). We should not perform both conversions1 and a test should be added to ensure this doesn't happen. - Converting
param_listto alistin.executemany()will saddle us with poor performance. We many have been passed a generator and the current approach will force all of the parameters to be materialized. The approach needed requires that we can peek at the first item in the generator without consuming the lot.
I'll provide a PR to your branch so that you can see what I mean.
Footnotes
-
We're either converting
formatparamstyle toqmarkor thepyformatparamstyle tonamed. Note that thesqlite3documentation only mentionsqmarkandnumeric, but the SQLite documentation indicates thatnamedis also supported. See also the relevant section in PEP 249. I'll try to get thesqlite3documentation updated. ↩
See ryancheley#1.
See python/cpython#99078. |
|
@felixxm is there anything left for me to do with this PR? If so, please let me know. 😁 |
|
@ryancheley Thanks 👍 I simplified comments. |
5200b94 to
54ea9fd
Compare
…SQLite. Co-authored-by: Nick Pope <[email protected]>
Fix to allow named parameters on raw sql queries with sqlite