Repository navigation
Order two lists item by item with <, <=, > and >= on Postgres and Oracle, and refuse toString() of a list or a map - #248
Merged
Merged
Conversation
…cle, and refuse toString() of a list or a map Port of liberation-data/drivine4j#349 (drivine4j PR #361). The SQL stores gave null for <, <=, > and >= of two lists. Where the statement makes either side a list, the two are now ordered item by item, as Cypher orders them: the first pair that is not equal decides, a list that starts the other comes first, and a pair with a null, of two kinds, or of two maps that differ is not ordered. - SqlCypherCompiler.list_order gives -1, 0 or 1, or null. Postgres walks the two lists with a recursive query by place; Oracle declares cy_list_order, a PL/SQL function over JSON_ELEMENT_T. It is declared through declare() each time it is called, with no flag of its own: declare() keeps one copy, and #244's trial compile gives back what it declared. A statement that writes, and a reduce() step, call no function the query declares, so there Oracle refuses the comparison with the spec's messages. - _compared_items gives temporal items as the comparison needs them: zoned values as their moments, durations and values of two kinds as maps of their kind (equal or not ordered), and a temporal list beside a text list as maps too, so the comparison is null. - toString() of a list or a map the statement makes is refused, as Neo4j (Cypher 5) refuses it. - The Cypher spec runs at v0.6.19. Every v0.6.18 statement compiles to the same SQL as before on Postgres and Oracle. Fixes #215
# Conflicts: # tests/integration/test_cypher_compiled.py # tests/sync_integration/test_cypher_compiled.py
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Port of liberation-data/drivine4j#349 (drivine4j PR #361, merged as 3c5c4e5).
The SQL stores gave null for
<,<=,>and>=of two lists. Where the statement makes either side a list, the two are now ordered item by item, as Cypher orders them. The first pair that is not equal decides, and a list that starts the other comes first. A pair with a null, of two kinds, or of two maps that differ is not ordered, so the comparison is null.list_orderwalks the two lists by place with a recursive query, asnulls_equaldoes.cy_list_orderis a PL/SQL function overJSON_ELEMENT_T. It is declared throughdeclare()every time it is called, with no declare-once flag of its own, matching Work an aggregate's argument out first where it would bind a value, so temporal arithmetic or text in an aggregate compiles to kilobytes #244:declare()keeps one copy, and Work an aggregate's argument out first where it would bind a value, so temporal arithmetic or text in an aggregate compiles to kilobytes #244's trial compile gives back what it declared.reduce()step, call no function the query declares. On Oracle, list order is refused there, with the messages the spec expects._compared_items: handles temporal items:toString(): refused for a list or a map that the statement makes, as Neo4j refuses it under Cypher 5.docs/04-statements.mdunder "Cypher on Postgres and Oracle": one in the general list, and one sentence in the Oracle bullet besidereduce.SQL: every v0.6.18 spec statement, 998 of them, compiles byte for byte as before on both Postgres and Oracle. The 33 statements new in v0.6.19 compile to the same SQL as Drivine for TypeScript's, once each library's driver wrapper is normalised.
Tests beyond the spec, ported from drivine4j:
tests/integration/test_cypher_compiled.py, and its sync copy, cover:[[]] < [[], 1];[] < [duration('P1D')];tests/unit/test_cypher_compiled_size.pychecks that Oracle declares the function once and calls it.tests/unit/test_cypher_refusals.pychecks thetoString()refusal and the two Oracle refusals.Known limits, kept as they are:
Fixes #215