8000 Fix proto file for deparse by gregnr · Pull Request #77 · launchql/libpg-query-node · GitHub
[go: up one dir, main page]

Skip to content

Fix proto file for deparse #77

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

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

gregnr
Copy link
Contributor
@gregnr gregnr commented Jun 27, 2024

Deparse is current broken for some queries like:

const sql = "INSERT INTO people (name, age) VALUES ('John', 28), ('Jane', 22);";
const result = await parseQuery(sql);
const newSql = await deparse(result);

// TypeError: Cannot set properties of undefined (setting '0')

This issue is related to the generated proto.js file (based on pg_query's .proto file) which defines its own String and Boolean classes. Turns out pbjs uses the global String() and Boolean() functions within its generated code, and this causes a name conflict in some places.

This PR demonstrates the changes needed to proto.js in order to fix this, but the final solution should find a way to automate this patch to proto.js at generation time (eg. via a Babel parser/generator) so that this fix is reproducible when generating proto.js for other .proto versions.

@pyramation pyramation merged commit d74df8b into launchql:15-deparse Jun 27, 2024
2 of 3 checks passed
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.

2 participants
0