Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR's main goal is to support query parametrization in tortoise-orm.
ValueWrapper
so they can be parametrizedParameter
to be dialect-aware. The original version in Pypika requires the user to specify the correct placeholder for the dialect (PyformatParameter
,QmarkParameter
, etc.) which is contradictory to other features where pypika generates a correct SQL according to the chosen dialect. For tortoise purposes, it is much more convenient to delegate the responsibility of generating correct SQL to pypika as much as possible.Parameter.get_sql
to avoid doing character escaping, type conversion, etc. if parametrization is used because database drivers usually do those things themselves for parametrized queries. Doing it twice causes subtle errors and extra latency.Parameterizer
which replacesListParameter
,DictParameter
, etc. This is mostly a refactoring change since the original code is quite convoluted and has questionable abstractions, e.g.ListParameter
isn't really a parameter but a container for values, theparameter
argument ofget_sql
isn't really a parameter but a container for values. This is change is making it harder to pull changes from pypika's upstream but I found it quite hard to use the original code for tortoise purposes.I'll rebase the branch when this is going to be merged tortoise/tortoise-orm#1776.