Repository navigation
docs: JSON path annotations and value restrictions work the same on MySQL and PostgreSQL - #318
Open
dimitri-yatsenko wants to merge 5 commits into
Open
dimitri-yatsenko wants to merge 5 commits into
dimitri-yatsenko wants to merge 5 commits into
Conversation
…ortable Describe the JSON path behavior of datajoint-python PR 1607: every accepted type annotation maps onto both backends or raises a DataJointError, a decimal without precision keeps its value, and a bool or number restriction compares JSON values with the same result on MySQL and PostgreSQL. Remove the warning that described the two fixed defects as open.
dimitri-yatsenko
requested review from
MilagrosMarin,
lum-agilyti and
ttngu207
November 21, 2026 03:13
…d differences A decimal without precision is exact on PostgreSQL only: MySQL's decimal(65,30) rounds beyond 30 decimal places and returns NULL from 1e35. Add the json/jsonb result types, values the type cannot hold, and integer annotations on fractional numbers to the differences. varchar without a length is cast as written on PostgreSQL. Only decimal and numeric take two arguments; bit alone becomes bit varying on PostgreSQL.
…ion and range on both backends - float, float8, double and float(p) with p from 25 to 53 are double precision on both backends; real, float4 and float(p) with p up to 24 are single precision. float(p) outside 1 to 53 raises a DataJointError. - Every integer annotation except unsigned is 64-bit on both backends. - Results that still differ: the digits a single-precision value comes back with, MySQL 8.0.21 comparing it in double precision, unsigned outside 0 to 2**63 - 1, integers outside the 64-bit range, and MySQL comparing JSON integers beyond 64 bits and numbers with more than 15 significant digits as 64-bit floats.
…s to the same range and precision The lead before the list of annotation mappings said every annotation has the same precision and range on both backends. unsigned has a different range (0 to 2**64 - 1 on MySQL, bigint on PostgreSQL), and MySQL returns single-precision values with 6 significant digits and MySQL 8.0.21 compares them in double precision. Name both exceptions in the lead.
… floating-point annotations; time types differ
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Documents datajoint-python PR 1607, which fixes datajoint-python issue 1563 and datajoint-python issue 1564. The JSON path access section of the type-system spec described both issues as open defects. This PR describes the behavior after the fix.
Merge this PR after datajoint-python PR 1607. The "Changed in 2.3.7" note assumes PR 1607 ships in 2.3.7.
Changes
In
src/reference/specs/type-system.md, section "JSON path access":varcharwithout a length is cast as written on PostgreSQL, where it has no length limit.unsignedhas the same range on both backends, and that each has the same precision (MySQL returns single-precision values with 6 significant digits, and MySQL 8.0.21 compares them in double precision; both are listed with the results that still differ). Floating-point precision follows PostgreSQL:float,float8,doubleandfloat(p)withpfrom 25 to 53 are double precision, andreal,float4andfloat(p)withpup to 24 are single precision (MySQL's ownREALis double precision and itsRETURNING FLOATsingle precision for everyp). Every integer annotation exceptunsignedis a 64-bit signed integer, sointandsmallintdo not narrow the range.decimalandnumerictake two arguments (precision and scale), thatchar(n),varchar(n),float(p)and the time types take one, and that a type given more arguments than it takes, orfloat(p)withpoutside 1 to 53, raises aDataJointError.decimal(65,30), which returns 30 decimal places, rounds beyond them (1e-40becomes0) and returnsNULLfrom1e35in magnitude, and MySQL stores a JSON number that has a fraction as a 64-bit float;1234567.89becomes1234570.0) and the shortest decimal that reads back as the same single-precision value on PostgreSQL (1234567.9), and MySQL 8.0.21 compares it in double precision, so{"specs.gain:real": 0.1}matches a stored0.1there and not on PostgreSQL, MySQL 8.0.46 or MySQL 8.4;unsignedis a 64-bit unsigned integer on MySQL andbiginton PostgreSQL: a negative value isNULLon MySQL and returned on PostgreSQL, and a value from2**63to2**64 - 1is returned on MySQL and fails the query on PostgreSQL;1/0on MySQL andTrue/Falseon PostgreSQL;jsonorjsonbannotation returns the JSON text as a string on MySQL and the decoded value on PostgreSQL;"abc"under:intor:date, or an integer outside-2**63to2**63 - 1under an integer annotation other thanunsigned) isNULLon MySQL and fails the query on PostgreSQL, and an integer annotation on a number with a fraction rounds it on MySQL and fails the query on PostgreSQL;char(n)isNULLon MySQL and cut on PostgreSQL;time,datetimeandtimestampwithout(n)drop the fraction of a second on MySQL and keep microseconds on PostgreSQL (write(6)for the same value), and atimeoutside 00:00:00 to 24:00:00 comes back on MySQL and fails the query on PostgreSQL;uuid,interval,bit,timetzandtimestamptzraise aDataJointErroron MySQL, andbitalone becomesbit varyingon PostgreSQL;-2**63to2**64 - 1, and every JSON number with a fraction or an exponent, as a 64-bit float, so a restriction by such a number compares rounded values on MySQL and exact values on PostgreSQL:{"specs.count": 2**70}also matches a stored2**70 + 1on MySQL. Integers within that range and numbers with up to 15 significant digits match the same rows on both.boolor number compares with the JSON value, with the same result on both backends for integers within the 64-bit range and numbers with up to 15 significant digits. It covers numbers by value (64matches64.0), booleans matching only JSON booleans, numbers never matching JSON strings, missing keys and JSONnullunder-, and NaN and infinity raising.floatwas single precision on MySQL andrealsingle precision on PostgreSQL, and thatsigned,unsigned,intandsmallintwere 32- or 16-bit on PostgreSQL.:intinstead of:unsigned.Tests
mkdocs build --strictruns in CI.