Sitelet https://github.com/humemai/arcadedb-embedded-python/pull/59
Skip to content

bindings: Decimal SQL parameters keep every digit, datetime/date parameters bind, datetimes keep microseconds (#58) - #59

Merged
tae898 merged 3 commits into
mainfrom
fix/param-decimal-datetime
Oct 2, 2026
Merged

tae898 merged 3 commits into
mainfrom
fix/param-decimal-datetime

Conversation

@tae898

@tae898 tae898 commented Oct 1, 2026 •

Copy link
Copy Markdown

Closes #58.

  • Positional SQL parameters now convert Decimal, date, and datetime through convert_python_to_java. Left to JPype, a Decimal reached the engine as a Double (Decimal("12345678901234567890.123456789012345678") was stored as 1.2345678901234567E+19, and WHERE amount = ? with the same value missed the rows holding it exactly), and a date or datetime was refused with "No matching overloads".
  • A datetime converts to a LocalDateTime with microseconds. The java.util.Date it used to build kept milliseconds, so DATETIME_MICROS and DATETIME_NANOS stored ...789000 for ...789123 and a lookup by the same value found nothing. The engine stores DATETIME as a UTC wall clock whatever the JVM's or the database's zone, so a naive value is now taken as that wall clock as it stands and reads back unchanged on every host (it used to be read as local time: 12:34 written on a UTC+9 host read back as 03:34); an aware value is converted to UTC and keeps its instant. On a non-UTC host, naive values written by earlier releases sit the zone offset away from the same wall clock written now; UTC hosts see no change. (Decided with the maintainer, 2026-10-02.)
  • Docs: docs/api/type_conversion.md gives the new mapping, the parameter behaviour, and the rule above; examples that store the current time use datetime.now(timezone.utc).

Engine side, for comparison: with the same values in Java a BigDecimal parameter is stored exactly on 26.8.1, 26.9.1, and main. The engine's own precision bug for SQL numeric literals is filed upstream as ArcadeData#8872.

Checked: the two new tests fail on the current dev wheel and pass on a wheel built from this branch; full suite 491 passed, 3 skipped; bandit (CI settings) clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WWcDr7TwvcfMsQkeYQVHZr

@tae898

tae898 commented Oct 1, 2026

Copy link
Copy Markdown
Author

On hold, not to merge on green. Passing a Python Decimal as a BigDecimal (this PR) routes it onto an engine path that compares two BigDecimals with their scale in a scan: against a stored 19.90 without an index, WHERE b = ? with Decimal("19.9") finds the record on main's bindings (where it crosses as a double) and finds nothing with this PR. The index, a range, and an equal-scale Decimal are unaffected. Measured with .notes/bench/repros/index-scan-matrix/decimal_scale.py.

Engine side filed as ArcadeData#8885 (a one-line compareTo fix). Merge this once that fix is in the engine the next bindings release packages, then re-run decimal_scale.py on the synced wheel. The CI failure on the previous head was this PR's own test assuming a non-UTC host; fixed in 7ac69aa (passes under UTC, Asia/Seoul and America/New_York; full suite under UTC 491 passed, 3 skipped).

tae898 and others added 3 commits October 2, 2026 20:38
…meters bind, datetimes keep microseconds (#58)

- Positional SQL parameters: Decimal, date, and datetime go through convert_python_to_java.
  Left to JPype, a Decimal reached the engine as a Double (38 digits stored as
  1.2345678901234567E+19, and a lookup by the same Decimal missed the exact rows), and a
  date or datetime matched no overload.
- A datetime converts to the UTC LocalDateTime of its instant, with its microseconds. The
  java.util.Date it used to build kept milliseconds, so DATETIME_MICROS and DATETIME_NANOS
  lost the rest and never matched their own value. The instant is unchanged: a naive value
  is still local time, as datetime.timestamp() reads it.
- Tests that fail on the previous wheel: test_decimal_parameter_keeps_every_digit,
  test_datetime_and_date_parameters. Full suite 491 passed, 3 skipped; bandit clean.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WWcDr7TwvcfMsQkeYQVHZr
…t passes on a UTC host (#58)

On a UTC machine the naive and the aware datetime are the same instant, so a
lookup by either finds all four rows; CI runs in UTC and failed on every
platform. The expected rows are now those whose instant equals the value's.
Passes under TZ=UTC, Asia/Seoul, and America/New_York; full suite under UTC:
491 passed, 3 skipped.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WWcDr7TwvcfMsQkeYQVHZr
…ed on every host (#58)

The engine stores DATETIME as a UTC wall clock whatever the JVM's or the
database's time zone (a LocalDateTime 12:34, an Instant 12:34Z and the string
'12:34' all store 12:34Z, measured under TZ=UTC and Asia/Seoul with the
database zone set to Asia/Seoul). A naive datetime was read as local time, so
12:34 written on a UTC+9 host read back as 03:34. It is now that wall clock as
it stands; an aware datetime is still converted to UTC and keeps its instant.

The test writes a naive 12:34:56.789123 and an aware 21:34:56.789123+09:00
through set() and a parameter, and checks that all four read back as the naive
value with epoch 12:34:56.789Z and that a lookup by either finds all four. It
fails on the previous code under TZ=Asia/Seoul (12:34 read back as 03:34) and
passes on this one under UTC, Asia/Seoul and America/New_York; the full suite
passes under UTC and Asia/Seoul (491 passed, 3 skipped).

Docs: the type-conversion notes state the rule, and the examples that store
the current time use datetime.now(timezone.utc).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WWcDr7TwvcfMsQkeYQVHZr
@tae898
tae898 force-pushed the fix/param-decimal-datetime branch from 68279eb to 4b27091 Compare October 2, 2026 11:46
@tae898
tae898 merged commit 596d5a6 into main Oct 2, 2026
48 checks passed
@tae898
tae898 deleted the fix/param-decimal-datetime branch October 2, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bindings: Decimal SQL parameters lose digits, datetime/date parameters are refused, datetimes lose microseconds

1 participant