Repository navigation
Convert JSON constructor arguments the way PostgreSQL does - #176
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
json_agg,json_build_array,json_build_object,to_jsonandjson_object_agghand SQLite the stored value of each argument, and SQLite's JSON functions encode that value as they find it. Wherever pg2sqlite stores a type as something other than PostgreSQL's value, the answer differs. Abyteacolumn, or auuidunderUuidRepresentation::Blob, fails withJSON cannot hold BLOB values. A boolean comes out as1, aNUMERIC(10,2)as its minor units, a timestamp without the ISOT, ajsoncolumn insidejson_build_arrayas a quoted string, and atimetzoffset keeps its:00.Every argument of these constructors and their
jsonbforms goes through one conversion injson_value.rs, chosen from the argument's declared or written type, so the constructors cannot drift apart again. Object keys take the value's JSON text, as PostgreSQL's do, and a JSON document used as a key is refused because PostgreSQL refuses it. Avector, a geometry or another extension type stored as a BLOB has no text form in SQL, so it is refused at translation rather than failing in SQLite at run time. A bare column whose table is outside the translation batch is refused by every constructor, asto_jsonandjson_aggalready refused it, since the conversion depends on its type.The new gauntlet test runs each constructor over every type on PostgreSQL 18 and on the translation, and compares the two through
jsonb. CI needs #174 first, because sqlparsermainaddedStatement::RevokeRole.