Repository navigation
Bind a NaN or an infinity as a BINARY_DOUBLE on Oracle, where the driver refused it - #599
Merged
Merged
Conversation
Draft
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 #575
On Oracle, a NaN or an infinity bound to a SQL statement was refused before it reached the store:
DPY-4004: invalid number. python-oracledb binds a Pythonfloatas aNUMBER, and aNUMBERholds neither. ADecimalthat is no finite number is bound as the float it stands for (#303), so it was refused too. For example,pm.query(QuerySpecification('SELECT $v FROM dual').bind({'v': float('inf')}))raised.Now:
BINARY_DOUBLE, which holds them. It is acursor.var(oracledb.DB_TYPE_BINARY_DOUBLE)holding the value. It reads back as the float, compares as a number, and stores in aBINARY_DOUBLEcolumn, throughqueryand through a cursor.NUMBER, as the object manager's JSON writes take it.Why the statement is also tagged: binding the variable alone wasn't enough. I measured this on Oracle with the bare driver:
BINARY_DOUBLE, a later run binding aNUMBERfor the same name makes the nextBINARY_DOUBLErun fail withORA-01426: numeric overflow. Oracle shares its cursor for the text and reads the value as aNUMBER.NUMBERdoesn't fail. Texts that differ by their binds' kinds don't either.So a statement that binds a NaN or an infinity gets a comment, on a line of its own, naming those binds:
/* drivine: binary doubles b0 */. That keeps it on its own shared cursor._BLOCK.matchstill reads the untagged text.Tests:
tests/integration/oracle/test_oracle_connection.py(and the generated sync copy):BINARY_DOUBLEcolumn;tests/unit/test_oracle_statement_cache.py, with no database:--comment.Whole suite with Oracle (
ORACLE_TESTS=true) on the final commit:tests/integration: 4714 passed, 291 skipped, 7 xfailed, 1 xpassed, 0 failedtests/sync_integration: 4644 passed, 290 skipped, 7 xfailed, 1 xpassed, 0 faileddrivine4j refuses them too: on Oracle, a
DoubleNaN bound to plain SQL fails withNaN, and an infinity withOverflow, from Oracle's JDBC driver. A port follows. Drivine for TypeScript is being checked.Review: 2 passes, last CLEAN.
_bindable's docstring to say a finite float is still aNUMBER.