Repository navigation
Read drivine4j's Postgres stand-ins for NaN and the infinities where a compiled statement says it holds them - #464
Merged
Merged
Conversation
…a compiled statement says it holds them (#459) CompiledCypher gets non_finite, False from Python's own compilers, so every statement reads as before. Where it is set, the statement's cursor reads json and jsonb with loaders of its own that map drivine4j's stand-ins by their exact decimal value, as PostgresCypherCompiler.read does: exactly 2e309 + 0.5 is NaN, at or past 1e309 +inf, at or past -1e309 -inf. Every other number reads as json.loads reads it. Nothing is registered on the connection or the process. The shared compiler's answers will say it. Port of liberation-data/drivine#673 part 2 (liberation-data/drivine#676).
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.
Closes #459. Port of liberation-data/drivine#673 part 2 (TS liberation-data/drivine#676).
Nothing changes under Python's own compiler. Python's compilers set the new flag False on every statement, and the goldens are unchanged. So this can land before Python switches to the shared compiler.
What changes
CompiledCyphergetsnon_finite: bool = False. None of Python's three compilers sets it.queryandopen_cursor, async and sync). Wherenon_finiteis set, the statement's cursor reads json and jsonb, text and binary, with loaders registered on that cursor alone (psycopg.types.json.set_json_loads(..., cursor)).PostgresCypherCompiler.readreads them:2e309 + 0.5is NaN;1e309is +inf;-1e309is -inf;json.loadsreads it.postgres_non_finite.py).rowsfield. Python already reads drivine4j's Oracle shape, one row per Cypher row, and has no one-row shape to tell apart.Tests
2e309,1e308,1e400,.4/.6, an exponent past Decimal's range);json.loadsparity for every other number;to_jsonb(2e309 + 0.5)and±(1e309 + 0.5)read as NaN/±inf with the flag on, throughqueryandopen_cursor, with and without a prelude;Verified