Add string functions: Trim, LTrim, RTrim, LPad, RPad, Replace#41
Add string functions: Trim, LTrim, RTrim, LPad, RPad, Replace#41seladb wants to merge 5 commits into
Conversation
|
@abondar @waketzheng @henadzit can you review this PR? |
|
@seladb Cloud you update the changelog? It would also be better if you could verify this PR in Tortoise (e.g., https://github.com/tortoise/tortoise-orm/pull/1851/changes). |
@waketzheng I opened this PR in tortoise as WIP: tortoise/tortoise-orm#2202 |
|
@seladb GPT mentioned that:
For example, ("SELECT REPLACE($1,'cd','xx')", ["abcde"])This is inconsistent with existing function wrappers such as Concat and Substring, where constant function arguments are emitted as query parameters. It also weakens the safety/consistency guarantee callers expect from get_parameterized_sql(). I think these wrappers should keep the default parameterization behavior for trim_chars, length, fill_text, search, and replacement, and add tests for the parameterized SQL output. Could you please take a look? |
- Revert c'tor param switch
I think GPT is correct, I removed |
|
Check this:
For example, on MySQL-style positional placeholders: currently produces: The SQL expects the first placeholder to be A fix would be to render/parameterize the arguments in the same order as the SQL text for the non-SQLite branch: |
trim_charsparameter in theTrimfunctionLTrim,RTrim,LPad,RPad,Replacefunctions (LPad,RPadare not supported in SQLite)