Description
Hi,
This library has unlocked the ability for me to add a SQL layer to FoundationDB (something often asked for by FDB community), via EctoFoundationDB. I'm in the very early and experimental stages of converting the parsed SQL from this library into an Ecto.Query that the EctoFoundationDB Adapter can convert into the FoundationDB transaction. For now I'm choosing not to pull :sql
as a dep into EctoFDB; using Ecto.Query as the standard representation for the time being.
I am wondering if you consider it safe for me to inspect the parsed representation of the SQL output by this library, and whether or not that representation is reasonably stable that I can develop against it? I'm using undocumented APIs to do it currently. 😅
I've noticed one inconsistency so far, perhaps it's a bug? Notice that the 'id' identifier is represented as {:ident, _, ["id"]}
and 'name' as {:name, _, []}
.
iex(1)> {:ok, _opts, _, _, _, _, tokens} = SQL.Lexer.lex("select id from my_table", {1, 0, nil}, 0, format: true)
iex(2)> SQL.Parser.parse(tokens)
[
{:select, [line: 0, column: 6, file: {1, 0, nil}],
[{:ident, [line: 0, column: 9, file: {1, 0, nil}], ["id"]}]},
{:from, [line: 0, column: 14, file: {1, 0, nil}],
[{:ident, [line: 0, column: 23, file: {1, 0, nil}], ["my_table"]}]}
]
iex(3)> {:ok, _opts, _, _, _, _, tokens} = SQL.Lexer.lex("select name from my_table", {1, 0, nil}, 0, format: true)
iex(4)> SQL.Parser.parse(tokens)
[
{:select, [line: 0, column: 6, file: {1, 0, nil}],
[{:name, [line: 0, column: 11, file: {1, 0, nil}], []}]},
{:from, [line: 0, column: 16, file: {1, 0, nil}],
[{:ident, [line: 0, column: 25, file: {1, 0, nil}], ["my_table"]}]}
]
Thanks for creating this project!