orql 0.1.0

A toy SQL parser for a subset of the Oracle dialect.
Documentation
use super::{Expr, Node};

/// An `ORDER BY` clause specifying at least one sort expression for a [crate::ast::Query]
#[derive(Debug)]
pub struct OrderBy<'s, ID> {
    /// `ORDER`
    pub order_token: Node<(), ID>,
    /// `SIBLINGS`
    pub siblings_token: Option<Node<(), ID>>,
    /// `BY`
    pub by_token: Node<(), ID>,
    /// the order expressions by which to sort
    pub expressions: Vec<OrderExpr<'s, ID>>,
}

/// A single order by expression
#[derive(Debug)]
pub struct OrderExpr<'s, ID> {
    /// the expression itself
    pub expr: Expr<'s, ID>,
    /// e.g. `ASC` or `DESC`
    pub direction: Option<Node<OrderDirection, ID>>,
    /// e.g. `NULLS FIRST` or `NULLS LAST`
    pub nulls: Option<OrderNulls<ID>>,
}

/// The desired order direction to an [OrderExpr]
#[derive(Debug)]
pub enum OrderDirection {
    /// `ASC`ending
    Asc,
    /// `DESC`ending
    Desc,
}

/// Preference of ordering null values
///
/// See [OrderExpr]
#[derive(Debug)]
pub struct OrderNulls<ID> {
    ///  the `NULLS` keyword ...
    pub nulls_token: Node<(), ID>,
    /// the preferred position of nulls, e.g. `FIRST` or `LAST`
    pub position: Node<OrderNullsPosition, ID>,
}

/// Order positioning for null values
///
/// See [OrderNulls]
#[derive(Debug)]
pub enum OrderNullsPosition {
    /// e.g. `NULLS FIRST`
    First,
    /// e.g. `NULLS LAST`
    Last,
}