Skip to content

Restrictions by JSON objects with non-ASCII text match; a uuid restricted by bytes raises DataJointError - #1735

Open
dimitri-yatsenko wants to merge 2 commits into
masterfrom
fix/1715-restriction-followups
Open

dimitri-yatsenko wants to merge 2 commits into
masterfrom
fix/1715-restriction-followups

Conversation

@dimitri-yatsenko

@dimitri-yatsenko dimitri-yatsenko commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Summary

Two restriction bugs that followed the restriction-value changes in 2.3.6 (GHSA-pv3r-mxv6-wccj):

  • A dict value for a JSON path, such as {"data.sub": {"name": "Zoë"}}, matched no rows when it held non-ASCII text. The value was rendered with json.dumps, which escapes non-ASCII characters (ë becomes \u00eb). Both servers render the stored JSON with the characters themselves. This was reproduced on MySQL 8.0 and also on PostgreSQL 15.
  • Restricting a uuid attribute by a bytes value raised a bare TypeError. Inserting bytes into a uuid attribute did the same.

Changes

  • A dict value for a JSON path is rendered with ensure_ascii=False. It is still quoted through the backend adapter, as before.
  • A uuid restriction value that cannot be read as a UUID raises DataJointError ("Badly formed UUID ..."), for bytes as for other types. The message now names the attribute once, without doubled backticks.
  • Inserting a bytes value into a uuid attribute raises DataJointError instead of TypeError.

Behavior change

  • A dict restriction on a JSON path whose value holds non-ASCII text: before, it matched no rows; now it matches the rows that hold that object.
  • A bytes value for a uuid attribute, in a restriction or an insert: before, a TypeError; now a DataJointError.

Tests

  • Unit tests in tests/unit/test_condition.py check the rendered JSON literal and the DataJointError for non-UUID values, on both backends.
  • Integration tests in tests/integration/test_restriction_values.py run on MySQL and PostgreSQL. They add the cases requested in the issue:
    • a JSON object value with non-ASCII text;
    • quoted values in restrictions on a join, a renamed proj, an aggr, and with dj.Top;
    • a cascading delete() and update1() with quoted values;
    • values from record arrays, numpy.void rows, and DataFrame rows.
  • The item_with_tags fixture inserts its rows as dicts, not positional tuples.
  • 8 of the new integration cases fail on the previous code. The full test suite passes on both backends.

Fixes #1715

…D values for uuid attributes

A dict value for a JSON path was rendered with json.dumps' default
ensure_ascii=True, so non-ASCII characters became \u escapes while both
servers render the stored JSON with the characters themselves. Such a
restriction matched no rows on MySQL or PostgreSQL.

A uuid attribute restricted or inserted with bytes raised a bare
TypeError from uuid.UUID. It now raises DataJointError, as other
badly formed UUID values do.

Adds the tests requested in the issue: quoted values in restrictions on
joins, renamed projections, aggregations and dj.Top; cascading delete
and update1; and values from record arrays, numpy.void rows and
DataFrame rows.

This branch has not been deployed

No deployments
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.

Restriction follow-ups: a uuid restricted by bytes raises TypeError; MySQL JSON object values with non-ASCII text never match

1 participant