orql

Crates.ioorql
lib.rsorql
version0.1.0
created_at2026-01-12 20:14:27.680631+00
updated_at2026-01-12 20:14:27.680631+00
descriptionA toy SQL parser for a subset of the Oracle dialect.
homepage
repositoryhttps://codeberg.org/xitep/orql.git
max_upload_size
id2038766
size727,763
(xitep)

documentation

https://docs.rs/orql/

README

orql

A toy SQL parser for a subset of the Oracle dialect.

motivation

The motivation for parser is to parse Oracle SQL statements into as an Abstract Syntax Tree while allowing the complete reconstruction of the orignally parsed source code. Therefore, the parser tries to preserve and expose token location as well as comments.

At the same time, the challenge is to not pay additional costs when not being interested in token location information and/or comments.

example

let sql = "select * from dual";
let stmts = parser::parse(sql).expect("bad sql!");
for stmt in stmts {
   println!("{:#?}", stmt);
}

Advanced examples demo'ing access to locations and comments can be found in the rustdoc of the individual, public modules.

status

not supported syntax

SQL syntax noted next is not supported by design:

multiple ON clauses

Example:

select *
  from (select 1 as alpha, 'alpha' as name from dual) a
  left join (select 1 as beta, 'beta' as name from dual) b
  join (select 1 as gamma, 'gamma' as name from dual) c
    on 1=1 -- causes `b` and `c` to be joined first ...
    on 1=1 -- ... on then this gets evaluated over of the previous inner join with `a`
;

Explanation: https://www.sqlservercentral.com/forums/topic/multiple-on-clauses-in-one-join

references / related projects

  • Oracle's SQL Language Reference

  • SQL 2016 Syntax Reference

  • datafusion-sqlparser-rs — A mature and complete SQL parser covering the full ANSI/ISO SQL Standard with support for database product specific extensions. Its exposed AST is general purpose — a union of all supported dialect specific features. Since sqlparser's AST doesn't contain nodes for every token in the parsed SQL, it's difficult to reconstruct the originally parsed SQL with regards to possible comments and indentation.

Commit count: 0

cargo fmt