Repository navigation
Make a date, a time or a moment from another temporal value, with the map's fields laid over its own, as drivine4j does - #320
Merged
Conversation
… map's fields laid over its own, as drivine4j does Ports drivine4j's #508 (merged as liberation-data/drivine4j#509), with the spec's liberation-data/drivine-cypher-spec#44, which v0.19.0 already holds. The compiler follows Drivine for TypeScript's port (liberation-data/drivine#503). - date(), localtime(), time(), localdatetime() and datetime() take a map with date, time or datetime, another temporal value, and lay the map's other fields over its own (SqlCypherCompiler._from_temporal, Temporals.over). A year, a month and a day replace the value's together, the date read as a date first so the store fails where they make none; a week, an ordinal day or a day of the quarter go through of_calendar; a quarter or a day of the week alone moves the date; a fraction given makes the whole fraction. A zoned value keeps the offset of what gives its time; a timezone given moves a zoned value there and names a local one's offset. - A value whose kind the statement doesn't tell is read by a CASE over the kinds that can give it; a known wrong kind is refused when compiling. A null or wrong-kind value or zone given by an expression fails as the statement runs, on the day 0, as Neo4j fails. - Refused as Neo4j refuses them: a field the kind hasn't, a datetime beside a date or a time, a value that is no temporal value, two calendars, a date that isn't whole beside a value that gives the time alone, a field of the time without the one above it, a number not whole or past its range, a time zone that is null or no offset. A zone by name (UTC among them) is refused as not compiled, now in any temporal map. - The whole-number check is shared with truncation (_whole_field), and the zone check (_zone_text) and the calendars (_calendars_of) with the calendar fields. The #317 holds come out of HELD. Fixes #317.
…her, and test calendar fields beside a time and Python temporal parameters
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#509 (drivine4j's #508), with liberation-data/drivine-cypher-spec#44, which the spec at v0.19.0 already holds. The compiler follows Drivine for TypeScript's port, liberation-data/drivine#503.
What changes
date(),localtime(),time(),localdatetime()anddatetime()take a map withdate,timeordatetime, which is another temporal value. The map's other fields are laid over that value's own:SqlCypherCompiler._from_temporalchecks the map, andTemporals.overbuilds the SQL.year,monthanddayreplace the value's together. The date is read as a date first, so the store fails where they make no date (Oracle included).week,ordinalDayordayOfQuartergoes throughof_calendar. Aquarteralone or adayOfWeekalone moves the date. Beside adayOfWeek, ayearmoves the date by that many years.timezonegiven moves a zoned value there and names a local value's offset.CASEover the possible kinds reads it. A kind known to be wrong is refused when compiling.datetimebeside adateor atime;'UTC'included, is now refused in any temporal map, not only one with calendar fields. That includes the constructor of a value given to another, as drivine4j does._whole_field, the whole-number and range check, is shared by truncation and from-temporal, as drivine #503's review had it._zone_textis shared with truncation._calendars_of,_calendar_dateandTemporals._dated/_date_ofare reused from Make a date or a moment from a week, an ordinal day or a quarter, and filter a grouping WITH by an aggregate in its WHERE, as drivine4j does, at Cypher spec v0.19.0 #318's calendar helpers.TRUNCATION_FIELD_NAMESbecomesFIELD_NOUNS.Tests
HELD:tests/unit/test_cypher_refusals.py.SQL comparison. Every statement of the spec at v0.19.0 (1,494) and of the openCypher TCK's features (4,119) was compiled for Postgres and Oracle, on main and on this branch:
datetime({…, timezone: 'Europe/Stockholm'}), TCK Temporal1 [10], Temporal3, Temporal5, Temporal6 and Temporal10 [8]). drivine4j#509 refuses them the same way.The 176 newly compiled statements were also compiled with drivine #503:
JSON_TRANSFORM(…, KEEP '$').Against Neo4j. drivine #503's reviewer built a grid of 3,015 statements: 10 source values × 5 targets × each variant, run as a
WITH, a stored property, anUNWIND, and a filteredUNWIND, plus the null cases. It was run here on Postgres and Oracle and compared with that grid's Neo4j answers (errors as errors, fractions to the microsecond): 0 differences on either store.Fixes #317