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

[GSP-1] Feature: Add support for extracting the full AST via means _other than_ encoding/json #13

Open
carsonfarmer opened this issue Sep 23, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request linear Sync issue with linear

Comments

@carsonfarmer
Copy link
Member

carsonfarmer commented Sep 23, 2022

Context

Currently, compiling this library to WASM provides an awesome resource for downstream consumers. The way the parser and AST are constructed makes it easy to parse SQL statements, and then return a normalized/parsed version of the string(s), as well as catch any errors along the way. However, since current WASM build tools in Go do not support Reflect properly, things like encoding/JSON to easily export the AST to WASM and beyond are stymied. There are some proposed solutions: tinygo-org/tinygo#447, but these don't work for our AST, because we take advantage of anonymous interfaces and other custom interfaces, for which there is no clean solution without reflect.

Ideal Solution

Ideally, our AST would either a) avoid custom interfaces (lame!), or b) would have a custom marshaling solution that could be used instead of relying on any form of reflection to extract structure. That way, a WASM build could simple (recursively) call the marshal function on the statements, and then return this to the JS side as bytes or a map[string]interface{} or other.

Ideas for marshaling could include real JSON bytes marshaling, or even simply outputting a set of JSON compatible values (map, int, float, nil, array) style solution.

GSP-1

@carsonfarmer carsonfarmer added documentation Improvements or additions to documentation enhancement New feature or request labels Sep 23, 2022
@brunocalza brunocalza added the linear Sync issue with linear label Mar 23, 2023
@brunocalza brunocalza changed the title Feature: Add support for extracting the full AST via means _other than_ encoding/json [GSP-1] Feature: Add support for extracting the full AST via means _other than_ encoding/json Mar 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request linear Sync issue with linear
Projects
No open projects
Status: 🆕 New
Development

No branches or pull requests

2 participants