Commit bd071be
authored
feat: add
## Which issue does this PR close?
- Closes #.
## Rationale for this change
When unparsing queries targeting databases like MSSQL, non-ASCII string
literals need special handling. MSSQL requires the `N'...'` (national
string literal) prefix for strings containing Unicode characters.
Currently the unparser always emits single-quoted strings with no way
for dialects to customize this behavior.
## What changes are included in this PR?
- Add a new `custom_string_literal_override` method to the `Dialect`
trait with a default implementation returning `None` (no override).
- Consolidate the `Utf8`, `Utf8View`, and `LargeUtf8` match arms in
`scalar_value_to_sql` and route them through the new dialect hook.
## Are these changes tested?
Yes. A test-only `MsSqlDialect` is defined in the test module to verify:
- ASCII strings produce standard single-quoted literals (no `N` prefix)
- Non-ASCII strings produce national string literals (`N'...`')
- The default dialect is unaffected (no `N` prefix regardless of
content)
It's used by Wren AI in production for a while:
Canner#8
## Are there any user-facing changes?
Yes. The `Dialect` trait gains a new method
`custom_string_literal_override`. This is a non-breaking change since
the method has a default implementation. Dialect implementors can
override it to customize string literal unparsing.custom_string_literal_override to unparser Dialect trait (#20590)1 parent 4166a6d commit bd071be
2 files changed
Lines changed: 84 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
251 | 262 | | |
252 | 263 | | |
253 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1294 | 1294 | | |
1295 | 1295 | | |
1296 | 1296 | | |
1297 | | - | |
1298 | | - | |
1299 | | - | |
1300 | | - | |
1301 | | - | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
1306 | 1303 | | |
1307 | 1304 | | |
1308 | | - | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
1309 | 1308 | | |
1310 | 1309 | | |
1311 | 1310 | | |
| |||
2397 | 2396 | | |
2398 | 2397 | | |
2399 | 2398 | | |
2400 | | - | |
2401 | 2399 | | |
2402 | 2400 | | |
2403 | 2401 | | |
| |||
2960 | 2958 | | |
2961 | 2959 | | |
2962 | 2960 | | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
2963 | 3025 | | |
2964 | 3026 | | |
2965 | 3027 | | |
| |||
0 commit comments