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 }}
Repository navigation
Restriction follow-ups: a uuid restricted by bytes raises TypeError; MySQL JSON object values with non-ASCII text never match #1715
Restricting a uuid attribute by a bytes value raises TypeError.prep_value in condition.py calls uuid.UUID(v) and catches only AttributeError and ValueError. With bytes, uuid.UUID raises TypeError, which escapes as a bare Python error. Raise the usual DataJointError ("Badly formed UUID ..."), or accept 16-byte values as uuid.UUID(bytes=v).
On MySQL, a JSON object value with non-ASCII text never matches. A dict value for a JSON path is rendered with json.dumps(v), which escapes non-ASCII characters (ensure_ascii=True). The stored JSON holds the characters themselves, so a restriction such as {"data.sub": {"name": "Zoë"}} matches no rows. Render the value with ensure_ascii=False, or compare through CAST(... AS JSON).
Tests
Restriction values are covered for plain tables. Add tests for:
restrictions on a join, on a renamed proj, on an aggr, and with dj.Top;
a cascading delete() and update1() with such restrictions;
values taken from record arrays, np.void rows, and DataFrame rows.
Reproduced against MySQL 8.0 and PostgreSQL 15 on current master:
{"data.sub": {"name": "Zoë"}} matches no rows on MySQL, as described. It also matches no rows on PostgreSQL. Both servers render the stored object as {"name": "Zoë"}, while json.dumps sends {"name": "Zo\u00eb"}.
Table & {"token": some_uuid.bytes} raises TypeError on both backends. Inserting bytes into a uuid attribute raises the same TypeError.
Both are fixed in #1735, together with the tests listed above.
Three related findings that the PR does not change:
A dict value is still compared as text, so key order matters. With a stored object {"a": 2, "b": 1}, the restriction {"data.sub": {"a": 2, "b": 1}} matches but {"data.sub": {"b": 1, "a": 2}} does not, on both backends. Both servers print object keys in their own normalized order. Comparing dict values as JSON values would remove this. That would build on the JSON value comparison proposed in fix(json): make JSON path annotations and value comparisons portable #1607, so it is left for a decision once that lands.
On PostgreSQL, a uuid attribute does not work end to end on current master. Inserting a uuid.UUID fails with column ... is of type uuid but expression is of type bytea. Restricting by a uuid.UUID fails with operator does not exist: uuid = bit. Fetching a row inserted with plain SQL fails with bytes is not a 16-char string. The integration test for bytes values therefore checks only the error on PostgreSQL, not matching rows.
Restricting an aggregation by an attribute and then fetching a subset of attributes that leaves that attribute out generates invalid SQL. For example, (Item.aggr(Tag, "name", n="count(*)") & {"name": "b"}).to_arrays("item_id") fails with Unknown column 'name' in 'having clause' on MySQL and column "name" does not exist on PostgreSQL. to_dicts() works. This looks like the restriction counterpart of keys() and to_arrays(attr) fail on an aggregation with dj.Top ordered by an aggregate #1670. The new tests fetch whole rows for that case.
Activity
dimitri-yatsenko commentedon Nov 21, 2026
Reproduced against MySQL 8.0 and PostgreSQL 15 on current
master:{"data.sub": {"name": "Zoë"}}matches no rows on MySQL, as described. It also matches no rows on PostgreSQL. Both servers render the stored object as{"name": "Zoë"}, whilejson.dumpssends{"name": "Zo\u00eb"}.Table & {"token": some_uuid.bytes}raisesTypeErroron both backends. Insertingbytesinto auuidattribute raises the sameTypeError.Both are fixed in #1735, together with the tests listed above.
Three related findings that the PR does not change:
{"a": 2, "b": 1}, the restriction{"data.sub": {"a": 2, "b": 1}}matches but{"data.sub": {"b": 1, "a": 2}}does not, on both backends. Both servers print object keys in their own normalized order. Comparing dict values as JSON values would remove this. That would build on the JSON value comparison proposed in fix(json): make JSON path annotations and value comparisons portable #1607, so it is left for a decision once that lands.uuidattribute does not work end to end on currentmaster. Inserting auuid.UUIDfails withcolumn ... is of type uuid but expression is of type bytea. Restricting by auuid.UUIDfails withoperator does not exist: uuid = bit. Fetching a row inserted with plain SQL fails withbytes is not a 16-char string. The integration test forbytesvalues therefore checks only the error on PostgreSQL, not matching rows.(Item.aggr(Tag, "name", n="count(*)") & {"name": "b"}).to_arrays("item_id")fails withUnknown column 'name' in 'having clause'on MySQL andcolumn "name" does not existon PostgreSQL.to_dicts()works. This looks like the restriction counterpart of keys() and to_arrays(attr) fail on an aggregation with dj.Top ordered by an aggregate #1670. The new tests fetch whole rows for that case.