Skip to content

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

@carsonfarmer

Description

@carsonfarmer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or requestlinearSync issue with linear

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions