You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 21, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 21, 2026. It is now read-only.
Database.lookup_by_key raises 'Unable to convert' for a datetime or date key that the same value bound to a SQL parameter finds #123
Level: bindings. db.lookup_by_key(type_name, keys, values) on a unique index over a DATETIME or DATE property fails with ArcadeDBError: Failed to lookup by key in 'Meeting': Unable to convert when the key is a Python datetime or date, although the record exists and SELECT ... WHERE at = ? with the same value finds it. The error does not say what could not be converted.
Repro
The script prints to stdout. The JVM's own log lines go to stderr and are discarded by the command below.
"""lookup_by_key raises 'Unable to convert' for a datetime or date key; the same value bound to a SQL parameter finds the record."""importdatetimeasdtimportosimporttempfileimportarcadedb_embeddedasarcadefromarcadedb_embedded.jvmimportstart_jvmstart_jvm(heap_size="2g")
db=arcade.create_database(os.path.join(tempfile.mkdtemp(prefix="hb18-"), "db"))
fortype_name, prop_typein (("Meeting", "DATETIME"), ("Holiday", "DATE")):
db.command("sql", f"CREATE DOCUMENT TYPE {type_name}")
db.command("sql", f"CREATE PROPERTY {type_name}.at {prop_type}")
db.command("sql", f"CREATE INDEX ON {type_name} (at) UNIQUE")
when=dt.datetime(2024, 5, 6, 7, 8, 9)
day=dt.date(2024, 5, 6)
withdb.transaction():
db.command("sql", "INSERT INTO Meeting SET at = ?, title = 'standup'", when)
db.command("sql", "INSERT INTO Holiday SET at = ?, title = 'spring day'", day)
fortype_name, keyin (("Meeting", when), ("Holiday", day)):
sql_hit=db.query("sql", f"SELECT title FROM {type_name} WHERE at = ?", key).first()
print(f"{type_name} / {key!r}")
print(" SQL WHERE at = ? ->", sql_hit.get("title") ifsql_hitelseNone)
try:
hit=db.lookup_by_key(type_name, ["at"], [key])
print(" db.lookup_by_key ->", hit.get("title") ifhitelseNone)
exceptExceptionase:
print(f" db.lookup_by_key -> {type(e).__name__}: {e}")
db.close()
Output
Wheel arcadedb_embedded-26.10.1.dev0-cp312-cp312-manylinux_2_34_x86_64.whl with its bundled JRE (OpenJDK 25.0.4.1), JPype 1.7.1, and Python 3.12.13. The engine build the wheel reports through com.arcadedb.Constants is 26.10.1-SNAPSHOT (build 04bb03ebec07fce19101595d65ca1e3bdf516755), an ancestor of upstream cecb369df9. The repository is at f92ac1381c8335249a6fde644cbf04594f6d6391, and the installed Python sources are identical to bindings/python/src/arcadedb_embedded/ at that commit.
Meeting / datetime.datetime(2024, 5, 6, 7, 8, 9)
SQL WHERE at = ? -> standup
db.lookup_by_key -> ArcadeDBError: Failed to lookup by key in 'Meeting': Unable to convert
Holiday / datetime.date(2024, 5, 6)
SQL WHERE at = ? -> spring day
db.lookup_by_key -> ArcadeDBError: Failed to lookup by key in 'Holiday': Unable to convert
Cause
lookup_by_key builds the key array with jpype.JArray(jpype.JObject)(values) (core.py L403) and does not pass the values through convert_python_to_java, which every other entry point uses for datetime, date, Decimal, bytes, and collections (core.py L98-L104). The message Unable to convert carries no detail, and I did not trace which layer raises it.
Expected
A datetime or date key finds the record, as it does as a SQL parameter.
Proposed fix
Convert each value before building the array:
--- a/bindings/python/src/arcadedb_embedded/core.py+++ b/bindings/python/src/arcadedb_embedded/core.py- values_array = jpype.JArray(jpype.JObject)(values)+ values_array = jpype.JArray(jpype.JObject)([convert_python_to_java(v) for v in values])
A run-time monkeypatch of the same conversion makes both lookups in the repro return their record.
Related issues
Nothing found upstream. Issue #58 (closed) made Decimal, date, and datetime work as SQL parameters and did not reach this method.
In this repository's tracker no issue is about this. The search for lookup_by_key found nothing.
Related reports from the same review: #127 (Instant conversion).
Activity
bindings: numpy bool, int32 arrays, lookup_by_key, append_samples, ge…