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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is true, the behaviour is not 100% the same, for example encoding JSON field as JSON does not add quotes when the value is not a string.
repro: https://dbfiddle.uk/YilhsCEk
JSON type must be preserved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not possible because mariadb protocol does not make the distinction in its metadata
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vuvova do you have an idea if the distinction of a JSON field is somehow possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can even try this in a MariaDB CLI session to see it's even stored like LONGTEXT:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MariaDB internally checks the JSON type like in https://github.com/MariaDB/server/blob/mariadb-12.1.1/sql/item_jsonfunc.cc#L1848.
Then I found https://github.com/MariaDB/server/blob/mariadb-12.1.1/sql/sql_type_json.h#L86 - is this really sent in the protocol?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it's true that the format is sent over as "json", it sends LONGTEXT in its type field, making an exception to this and transforming this to JSON is lying. See also https://mariadb.com/docs/server/reference/data-types/string-data-types/json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In atk4/data we need to detect the type is JSON - can https://github.com/MariaDB/server/blob/mariadb-12.1.1/sql/sql_type_json.h#L86 be accessed right now or can it be make accessible either by returning JSON here or via some other extended field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say "lying" would be correct here:
format=json
is set (if and only if the type is JSON internally), the type is JSON in realityThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, possible since 2020.
But only if the client sets MARIADB_CLIENT_EXTENDED_TYPE_INFO capability bit.
https://jira.mariadb.org/browse/MDEV-17832
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I'll look into it.