bustubx 0.3.0

A simple relational database written in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::error::BustubxResult;
use sqlparser::{ast::Statement, dialect::PostgreSqlDialect, parser::Parser};

pub fn parse_sql(sql: &str) -> BustubxResult<Vec<Statement>> {
    let stmts = Parser::parse_sql(&PostgreSqlDialect {}, sql)?;
    Ok(stmts)
}

#[cfg(test)]
mod tests {

    #[test]
    pub fn test_parser() {
        let sql = "select * from (select * from t1)";
        let stmts = super::parse_sql(sql).unwrap();
        println!("{:#?}", stmts[0]);
    }
}