Fix array positions rendering as object keys, and subscripts served from the statement cache - #314
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…wn method in query caching tests
| - Compiler: Fixed array indexes rendering as object keys, as in `arr['1']`. | ||
| Added support for array slices, and for columns and expressions as indexes | ||
| - Fixed the statement cache returning results for another key on | ||
| `ObjectArray` and `JSON` subscripts and escaped quotes in object keys. | ||
| - Statements with a literal subscript, as in `js['x']` run with | ||
| `execution_options(compiled_cache=None)` |
There was a problem hiding this comment.
PR looks ace, but I think you just need to signal more changes:
| - Compiler: Fixed array indexes rendering as object keys, as in `arr['1']`. | |
| Added support for array slices, and for columns and expressions as indexes | |
| - Fixed the statement cache returning results for another key on | |
| `ObjectArray` and `JSON` subscripts and escaped quotes in object keys. | |
| - Statements with a literal subscript, as in `js['x']` run with | |
| `execution_options(compiled_cache=None)` | |
| - Compiler: Fixed array indexes rendering as object keys, as in `arr['1']`. | |
| Added support for array slices, and for columns and expressions as indexes | |
| - Compiler: Fixed cached statements on `sa.JSON` and `ObjectArray` columns | |
| reusing the subscript of an earlier statement, which returned values of | |
| another key. Fixed object keys containing a quote | |
| - Compiler: A statement with a literal subscript can't run with `executemany()` | |
| on a cached engine. For that, use `execution_options(compiled_cache=None)` | |
| - Compiler: An integer subscript on a nested object renders as an array | |
| position. Write the key as a string, as in `obj['n']['1']` | |
| - Compiler: `bool`, `float` and `None` subscripts raise `CompileError` |
Summary of the changes / Why this is an improvement
CrateDB rejects a bare bind parameter as a position or key (
arr[?]fails with Parameter substitution is not supported in subscript index), but accepts one inside an expression (arr[id + ?],arr[abs(?)], also as anUPDATEtarget).literal_execute).type_coerce(literal(2), Integer), is unwrapped and treated as a plain value.start:stop, with bind parameters as bounds. A step raisesCompileError.obj[1]→obj['1'], as onmain), because CrateDB never accepts a position there.CompileError.Behavior changes
ObjectArrayandsa.JSONsubscripts no longer return a cached statement's results.bool,floatandNonesubscripts raiseCompileError. Before, they rendered as keys such asobj['True'].WHERE js['x'] = :v, can't run withexecutemany(): SQLAlchemy doesn't supportliteral_executethere, the same restriction it has for expandingIN.References for implementation
Out of scope
tests/query_caching.pyrenamed totests/query_caching_test.pyto align with naming on all tests.Checklist