gwenn / lemon-rs

LALR(1) parser generator for Rust based on Lemon + SQL parser
The Unlicense
48 stars 10 forks source link

Get table names from parsed SQL statement #60

Closed tokcum closed 3 months ago

tokcum commented 3 months ago

Hi,

is it possible to get the table names from a parsed SQL statement? I've extracted a One from a simple SQL statement parsed by Parser. This is what I have so far:

Select { distinctness: None, columns: [Star], from: Some(FromClause { select: Some(Table(QualifiedName { db_name: None, name: Name("users"), alias: None }, None, None)), joins: None, op: None }), where_clause: None, group_by: None, window_clause: None }

The SQL statement behind this is SELECT * FROM users;

How could I access the FromClause? I've implemented TokenStream but it returns the SQL tokens only, not my own literals. Do I miss something?

Any advice appreciated. Thank you.

tokcum commented 3 months ago

Reading the source code, I managed to fully dissect the SQL statement and access the data in the FromClause.

Thank you for this crate!