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
Use self._wrapper_cls in QueryBuilder.set #386
Conversation
This commit fixes a problem where the QueryBuilder.set method always used the ValueWrapper class instead of the instance's _wrapper_cls. Signed-off-by: Petter Nyström <jimorie@gmail.com>
I have realized there are a lot of other places where the QueryBuilder's
I kind of expected SQLiteQuery's custom ValueWrapper to turn all instances of Is this working as intended? |
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.
I looked through the code and this is the only instance where ValueWrapper is instantiated directly, rather than using _wrapper_cls
aside from a couple of cases in the Query subclass for MySQL. Could fix the references there if you'd like but it's not presently posing a problems, so I don't think it's necessary to fix in the scope of this PR. Let me know if you'd like to fix it or not or if I should go ahead and merge this PR.
I'm not really bothered about the use in the MySQL dialect code -- I assume it's not a problem there. But it seems to be a problem that the I guess the problem is in It looks like a lot of work to fix this, unfortunately. My first instict is that all Would you consider a change that introduced Do you have any other ideas how to make the SQLLite dialect's use of a custom |
Ah I see what you mean, definitely an oversight. I think the implementation of this Something like this:
Then we could just get rid of the |
Well, as a user of the library I definitely appreciate that I can write my own dialect and have it able to manipulate how it formats individual terms in the output, or attach side effects to them. I can see this being provided either by a configurable I can understand if you deem this as out of scope for what the library should offer, though. For the record, my actual use case here was to write my own dialect that automatically turned all values used in the query into |
I guess either way you would need to override the main Query class to make a dialect. There you could then override the _wrap_constant function, instead of providing a separate version of ValueWrapper for each dialect. Looks like the wrapper_cls might be inaccessible in a lot of places where it might be necessary to use, so it would certainly add complexity passing that around to all the different objects in the object tree |
Sorry, I forgot about this. Glad to see it merged even though it didn't do enough for my purposes of generating parameterized SQL. I ended up doing some post-processing in the |
This commit fixes a problem where the QueryBuilder.set method always
used the ValueWrapper class instead of the instance's _wrapper_cls.
Signed-off-by: Petter Nyström jimorie@gmail.com