From edfc6ba6603e10409ff5aacbab8f3151de27c0d0 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Sat, 3 Oct 2026 18:44:34 +0900 Subject: [PATCH 1/2] bindings docs: known issues for upstream #9014, #9017, #9021, and #9027, with workaround tests and strict xfail tripwires (#106) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01DeKEhHXJTy1H1GgbfBZ8mL --- bindings/python/docs/guide/known-issues.md | 83 ++++++++ .../tests/test_declared_type_known_issues.py | 185 ++++++++++++++++++ 2 files changed, 268 insertions(+) create mode 100644 bindings/python/tests/test_declared_type_known_issues.py diff --git a/bindings/python/docs/guide/known-issues.md b/bindings/python/docs/guide/known-issues.md index 807b2f79233..79439d80d9b 100644 --- a/bindings/python/docs/guide/known-issues.md +++ b/bindings/python/docs/guide/known-issues.md @@ -320,3 +320,86 @@ with db.transaction(): Tests: `test_vertex_new_edge_keeps_a_null_and_refuses_an_out_of_range_short` checks this workaround, and the strict `xfail` tests next to it start failing the suite when an engine fix reaches the wheel, which is the cue to remove this entry. + +## `CREATE PROPERTY` with `mandatory` and `notnull` over records that lack the property makes `ORDER BY` drop them + +ArcadeDB [#9017](https://github.com/ArcadeData/arcadedb/issues/9017); measured through the +bindings on a 26.10.1 snapshot. The `ORDER BY` answers are new on main: the same Java +reproduction returns every record on 26.9.1 and on the 2026-09-17 main snapshot. + +`CREATE PROPERTY T.v INTEGER (mandatory true, notnull true)` is accepted over records that +have no `v`, and the planner then trusts the two flags to mean that an index on `v` holds +every record. With five records and a `NOTUNIQUE` index on `v`, where the fifth has no `v`, +`SELECT id FROM T ORDER BY v` returned `[1, 2, 3, 4]` while `count(*)` was 5 and +`ORDER BY id` returned all five. `ALTER PROPERTY ... MANDATORY true` refuses the same +records since upstream #8956; `CREATE PROPERTY` and the openCypher `CREATE CONSTRAINT` +statements do not. + +Give every record the property before you declare the constraints, or declare them on a type +that is still empty. A type that is already declared over such records answers `ORDER BY` +correctly again after `ALTER PROPERTY T.v MANDATORY false` and `ALTER PROPERTY T.v NOTNULL +false`; both ways returned all five records on the same reproduction. + +```python +with db.transaction(): + db.command("sql", "UPDATE T SET v = 0 WHERE v IS NULL") +db.command("sql", "CREATE PROPERTY T.v INTEGER (mandatory true, notnull true)") +``` + +Tests: `tests/test_declared_type_known_issues.py`; its strict `xfail` tests start failing the suite when an engine fix reaches the wheel, which is the cue to remove this entry. + + +## An index on an `INTEGER` or `LONG` answers for a bound with a fraction as if it were rounded + +ArcadeDB [#9021](https://github.com/ArcadeData/arcadedb/issues/9021); measured through the +bindings on a 26.10.1 snapshot, and in Java on 26.9.1 and the 2026-09-17 main snapshot. + +On an indexed `INTEGER` holding 11, 12, and 13, a bound of `12.5` (a Python `float`, as a +parameter or a literal) gives other rows than the same query on an unindexed copy: +`i = :b` returned `[12]` against `[]`, `i >= :b` returned `[12, 13]` against `[13]`, and +`i < :b` returned `[11]` against `[11, 12]`. On an indexed `LONG`, a `float` of `1e19` finds +the record holding `Long.MAX_VALUE`. Other bounds that need no rounding are not affected. + +Round the bound yourself, in the direction that keeps the same rows: `math.ceil(b)` for `>=` +and `<`, `math.floor(b)` for `>` and `<=`, and do not run an equality query when +`b != int(b)`, because no integer equals it. For all four range operators the rounded +integer bound returned the same rows as the unindexed scan. + +```python +import math + +b = 12.5 +rows = db.query("sql", "SELECT i FROM T WHERE i >= :b", {"b": math.ceil(b)}).to_list() +``` + +Tests: `tests/test_declared_type_known_issues.py`; its strict `xfail` tests start failing the suite when an engine fix reaches the wheel, which is the cue to remove this entry. + + +## A value that cannot be converted is stored as `NULL`, and `''` as `0`, in a declared numeric property + +ArcadeDB [#9014](https://github.com/ArcadeData/arcadedb/issues/9014) and +[#9027](https://github.com/ArcadeData/arcadedb/issues/9027); measured through the bindings +on a 26.10.1 snapshot, and in Java on 26.9.1 and the 2026-09-17 main snapshot. + +Writing `True`, a `list`, or a `dict` to a declared `BYTE`, `SHORT`, `INTEGER`, `LONG`, +`FLOAT`, or `DOUBLE` property is accepted and stores `NULL`: `doc.set("i", True)`, +`doc.set("i", [1, 2])`, and `doc.set("i", {"a": 1})` followed by `save()` all read back +`None`, with no error (the string `'abc'` is refused). An empty string bound as a parameter +to a `SHORT`, `INTEGER`, `LONG`, `FLOAT`, or `DOUBLE` is stored as `0`, while `BYTE` and +`DECIMAL` refuse it. + +Convert in Python before you write. `int(value)` raised `TypeError` for the list and the +dict, gave `1` for `True` and `7` for `"7"`, and an empty string is better mapped to `None` +explicitly than left to the engine. + +```python +def to_int(value): + return None if value == "" else int(value) + + +with db.transaction(): + doc = db.new_document("N").set("i", to_int(user_value)) + doc.save() +``` + +Tests: `tests/test_declared_type_known_issues.py`; its strict `xfail` tests start failing the suite when an engine fix reaches the wheel, which is the cue to remove this entry. diff --git a/bindings/python/tests/test_declared_type_known_issues.py b/bindings/python/tests/test_declared_type_known_issues.py new file mode 100644 index 00000000000..310f81a48f1 --- /dev/null +++ b/bindings/python/tests/test_declared_type_known_issues.py @@ -0,0 +1,185 @@ +"""Engine findings about declared properties that reach Python users (known-issues.md). + +Each finding has a test of its documented workaround, which must keep passing, and a +strict `xfail` for the engine behavior itself. The strict `xfail` is a tripwire, as +`test_restore_sql.py` used for #6096: when an engine fix reaches the wheel the test starts +passing, the suite fails, and the known-issues.md entry is removed. + +Upstream: ArcadeData/arcadedb #9014 and #9027 (a value that cannot be converted is stored +as NULL, and '' as 0), #9017 (CREATE PROPERTY mandatory + notnull over records that lack +the property, then ORDER BY drops them), #9021 (an index on INTEGER answers for a fractional +bound as if it were rounded). +""" + +import math + +import arcadedb_embedded as arcadedb +import pytest + + +def _five_records_one_without_v(db, name): + db.command("sql", f"CREATE DOCUMENT TYPE {name}") + with db.transaction(): + for i in range(1, 5): + db.command( + "sql", f"INSERT INTO {name} SET id = {i}, v = {i}" + ) # nosec B608 - fixed names + db.command("sql", f"INSERT INTO {name} SET id = 5") # nosec B608 - fixed names + + +def _ids_by_v(db, name): + query = f"SELECT id FROM {name} ORDER BY v" # nosec B608 - fixed names + return sorted(r.get("id") for r in db.query("sql", query)) + + +@pytest.mark.xfail( + strict=True, + reason="ArcadeData/arcadedb#9017: CREATE PROPERTY (mandatory, notnull) is accepted over records " + "that lack the property, and an index-ordered ORDER BY then drops them", +) +def test_order_by_keeps_records_after_constraints_declared_over_missing_values( + temp_db_path, +): + with arcadedb.create_database(temp_db_path) as db: + _five_records_one_without_v(db, "Declared") + db.command( + "sql", "CREATE PROPERTY Declared.v INTEGER (mandatory true, notnull true)" + ) + db.command("sql", "CREATE INDEX ON Declared (v) NOTUNIQUE") + assert _ids_by_v(db, "Declared") == [1, 2, 3, 4, 5] + + +def test_order_by_workarounds_for_constraints_over_missing_values(temp_db_path): + """known-issues.md: give every record the property first, or relax the constraints.""" + with arcadedb.create_database(temp_db_path) as db: + _five_records_one_without_v(db, "Repaired") + with db.transaction(): + db.command("sql", "UPDATE Repaired SET v = 0 WHERE v IS NULL") + db.command( + "sql", "CREATE PROPERTY Repaired.v INTEGER (mandatory true, notnull true)" + ) + db.command("sql", "CREATE INDEX ON Repaired (v) NOTUNIQUE") + assert _ids_by_v(db, "Repaired") == [1, 2, 3, 4, 5] + + _five_records_one_without_v(db, "Relaxed") + db.command( + "sql", "CREATE PROPERTY Relaxed.v INTEGER (mandatory true, notnull true)" + ) + db.command("sql", "CREATE INDEX ON Relaxed (v) NOTUNIQUE") + db.command("sql", "ALTER PROPERTY Relaxed.v MANDATORY false") + db.command("sql", "ALTER PROPERTY Relaxed.v NOTNULL false") + assert _ids_by_v(db, "Relaxed") == [1, 2, 3, 4, 5] + + +def _indexed_and_plain_integers(db): + for name in ("Indexed", "Plain"): + db.command("sql", f"CREATE DOCUMENT TYPE {name}") + db.command("sql", f"CREATE PROPERTY {name}.i INTEGER") + db.command("sql", "CREATE INDEX ON Indexed (i) NOTUNIQUE") + with db.transaction(): + for value in (11, 12, 13): + db.command( + "sql", f"INSERT INTO Indexed SET i = {value}" + ) # nosec B608 - fixed names + db.command( + "sql", f"INSERT INTO Plain SET i = {value}" + ) # nosec B608 - fixed names + + +def _matching(db, name, condition, bound): + query = f"SELECT i FROM {name} WHERE {condition}" # nosec B608 - fixed names + return sorted(r.get("i") for r in db.query("sql", query, {"b": bound})) + + +@pytest.mark.xfail( + strict=True, + reason="ArcadeData/arcadedb#9021: an index on an INTEGER answers for a bound with a fraction as if " + "it were rounded (i = 12.5 returns 12, i < 12.5 misses 12)", +) +@pytest.mark.parametrize("condition", ["i = :b", "i >= :b", "i < :b"]) +def test_index_agrees_with_scan_for_a_fractional_bound(temp_db_path, condition): + with arcadedb.create_database(temp_db_path) as db: + _indexed_and_plain_integers(db) + assert _matching(db, "Indexed", condition, 12.5) == _matching( + db, "Plain", condition, 12.5 + ) + + +def test_rounded_bound_workaround_for_a_fractional_bound(temp_db_path): + """known-issues.md: ceil for >= and <, floor for > and <=, and no equality query for a + bound that is not an integer.""" + bound = 12.5 + rounded = { + "i >= :b": math.ceil(bound), + "i > :b": math.floor(bound), + "i <= :b": math.floor(bound), + "i < :b": math.ceil(bound), + } + with arcadedb.create_database(temp_db_path) as db: + _indexed_and_plain_integers(db) + for condition, integer_bound in rounded.items(): + assert _matching(db, "Indexed", condition, integer_bound) == _matching( + db, "Plain", condition, bound + ), condition + + +def _stored_integer(db, value): + """Write `value` to a declared INTEGER with Document.set and read it back (None when stored NULL).""" + with db.transaction(): + doc = db.new_document("N").set("tag", "x").set("i", value) + doc.save() + row = db.query("sql", "SELECT i FROM N WHERE tag = 'x'").first() + with db.transaction(): + db.command("sql", "DELETE FROM N") + return row.get("i") + + +@pytest.mark.xfail( + strict=True, + reason="ArcadeData/arcadedb#9014: a bool, list, or dict written to a declared INTEGER is stored as NULL " + "instead of being refused", +) +@pytest.mark.parametrize( + "value", [True, [1, 2], {"a": 1}], ids=["bool", "list", "dict"] +) +def test_an_inconvertible_value_is_refused_not_stored_as_null(temp_db_path, value): + with arcadedb.create_database(temp_db_path) as db: + db.command("sql", "CREATE DOCUMENT TYPE N") + db.command("sql", "CREATE PROPERTY N.i INTEGER") + with pytest.raises( + Exception + ): # noqa: B017 - the engine's Java IllegalArgumentException + _stored_integer(db, value) + + +@pytest.mark.xfail( + strict=True, + reason="ArcadeData/arcadedb#9027: an empty string bound to a declared INTEGER is stored as 0", +) +def test_an_empty_string_is_not_stored_as_zero(temp_db_path): + with arcadedb.create_database(temp_db_path) as db: + db.command("sql", "CREATE DOCUMENT TYPE N") + db.command("sql", "CREATE PROPERTY N.i INTEGER") + try: + with db.transaction(): + db.command("sql", "INSERT INTO N SET tag = 'x', i = :v", {"v": ""}) + except Exception: # noqa: BLE001 - a refusal is what a fixed engine does + return + assert db.query("sql", "SELECT i FROM N WHERE tag = 'x'").first().get("i") != 0 + + +def _to_int(value): + """known-issues.md: convert in Python first; an empty string means no value.""" + return None if value == "" else int(value) + + +def test_convert_in_python_workaround_for_inconvertible_values(temp_db_path): + with arcadedb.create_database(temp_db_path) as db: + db.command("sql", "CREATE DOCUMENT TYPE N") + db.command("sql", "CREATE PROPERTY N.i INTEGER") + for bad in ([1, 2], {"a": 1}): + with pytest.raises(TypeError): + _to_int(bad) + assert _stored_integer(db, _to_int("7")) == 7 + assert _stored_integer(db, _to_int(True)) == 1 + assert _stored_integer(db, _to_int("")) is None From 1a7538edbd3ed74deac8337eb5f448b400d976a0 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Sat, 3 Oct 2026 18:55:24 +0900 Subject: [PATCH 2/2] known-issues: say what a Tests line means (#106) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01DeKEhHXJTy1H1GgbfBZ8mL --- bindings/python/docs/guide/known-issues.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bindings/python/docs/guide/known-issues.md b/bindings/python/docs/guide/known-issues.md index 79439d80d9b..ac09851e4a7 100644 --- a/bindings/python/docs/guide/known-issues.md +++ b/bindings/python/docs/guide/known-issues.md @@ -5,6 +5,9 @@ the wrong rows, or refuse a read or a write. Each entry names the versions it wa on, what you see, a workaround that was checked on the same reproduction, and the release that fixes it once there is one. Entries leave this page when the fix ships in a release these bindings package. +An entry with a `Tests:` line has a test of its workaround and a strict `xfail` test of the +engine behavior; the `xfail` starts failing the suite when a fix reaches the wheel, which is +the cue to remove the entry. ## A SQL decimal literal keeps only the digits a double holds