1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use std::ops::Deref;
use super::{Node, Select};
/// A parsed SQL statement
#[derive(Debug)]
pub struct Statement<'s, ID> {
/// the statement itself
pub statement: StatementType<'s, ID>,
/// the terminating semicolong, if any. e.g. `;` or end-of-file
// XXX may need to include the type of the terminal in future, e.g. `;` or `/`
pub terminator: Option<Node<(), ID>>,
}
impl<'s, ID> Deref for Statement<'s, ID> {
type Target = StatementType<'s, ID>;
fn deref(&self) -> &Self::Target {
&self.statement
}
}
/// A SQL statement
#[derive(Debug)]
pub enum StatementType<'s, ID> {
/// An empty statements, e.g. a single `;` on its own,
/// possibly associated with comments
Empty,
/// A query statement, e.g. `SELECT * FROM dual`
///
/// See <https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/SELECT.html>
// XXX consider putting into a `Box<...>`
Select(Box<Select<'s, ID>>),
// XXX Insert
// XXX Update
// XXX Delete
// XXX Merge
}