Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid json outfuncs key duplication #246

Open
wants to merge 3 commits into
base: 16-latest
Choose a base branch
from

Conversation

lfittl
Copy link
Member

@lfittl lfittl commented Apr 26, 2024

Reviewing #244 I noticed that we appear to incorrectly wrap ival, sval, etc twice when outputting A_Const nodes. That does not match the Protobuf JSON approach, which intends to have a oneof represented the same way as having a simple field of that type (see protocolbuffers/protobuf#3928 (comment)).

This change now matches the manual JSON output to the generate JSON protobuf. This changes
an output of {"A_Const":{"ival":{"ival":123}}} to be {"A_Const":{"ival":123}} instead.

This is a breaking change in the JSON output. As such, this would warrant a minor version bump (or we could hold off until the Postgres 17 release). Note that this does not change anything in the binary Protobuf output, which is used by most wrapper libraries.

me.gorkov and others added 3 commits April 16, 2024 16:39
The JSON format intends to follow the structure of the Protobuf JSON
representation of the parse nodes. The A_Const parse node is the only
one making use of the "oneof" construct (matching the union in the C code)
and was using a different representation in the generated JSON protobuf
(outputting "ival" once), vs the manual JSON output (outputting it twice).

Match the manual JSON output to the generate JSON protobuf. This changes
an output of "{"A_Const":{"ival":{"ival":123}}}" to be
"{"A_Const":{"ival":123}}" instead.

This is a breaking change in the JSON output.
@lfittl
Copy link
Member Author

lfittl commented Apr 26, 2024

Hmm, it looks like protobuf-cpp does not follow the spec here, since it does output the keys twice (see test failures). Need to debug this further.

@msullivan
Copy link

We (https://github.com/edgedb/edgedb) use the JSON output and are trying to upgrade to 16 but are blocked by the int constant thing. We would definitely appreciate a fix on 16 (though we can make a temporary fork with a direct fix if needed)

@msullivan
Copy link

It looks like the mismatch that was happening with protobuf wasn't actually the double key situation, but that protobuf still left out the value on 0

@msullivan
Copy link

I've submitted #249

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.

None yet

2 participants