sqlparser::ast

Trait Spanned

Source
pub trait Spanned {
    // Required method
    fn span(&self) -> Span;
}
Expand description

Trait for AST nodes that have a source location information.

§Notes:

Source Span are not yet complete. They may be missing:

  1. keywords or other tokens
  2. span information entirely, in which case they return Span::empty().

Note Some impl blocks (rendered below) are annotated with which nodes are missing spans. See this ticket for additional information and status.

§Example

let dialect = GenericDialect {};
let sql = r#"SELECT *
  FROM table_1"#;
let statements = Parser::new(&dialect)
  .try_with_sql(sql)?
  .parse_statements()?;
// Get the span of the first statement (SELECT)
let span = statements[0].span();
// statement starts at line 1, column 1 (1 based, not 0 based)
assert_eq!(span.start, Location::new(1, 1));
// statement ends on line 2, column 15
assert_eq!(span.end, Location::new(2, 15));

Required Methods§

Source

fn span(&self) -> Span

Return the Span (the minimum and maximum Location) for this AST node, by recursively combining the spans of its children.

Implementors§

Source§

impl Spanned for AccessExpr

Source§

impl Spanned for AlterColumnOperation

§partial span

Missing spans:

Source§

impl Spanned for AlterIndexOperation

Source§

impl Spanned for AlterTableOperation

§partial span

Missing spans:

Source§

impl Spanned for AssignmentTarget

Source§

impl Spanned for ColumnOption

§partial span

Missing spans:

Source§

impl Spanned for ConflictTarget

Source§

impl Spanned for CopySource

Source§

impl Spanned for CreateTableOptions

Source§

impl Spanned for ExcludeSelectItem

Source§

impl Spanned for Expr

§partial span

Most expressions are missing keywords in their spans. f.e. IS NULL <expr> reports as <expr>::span.

Missing spans:

Source§

impl Spanned for FromTable

Source§

impl Spanned for FunctionArg

Source§

impl Spanned for FunctionArgExpr

§partial span

Missing spans:

Source§

impl Spanned for FunctionArgumentClause

Source§

impl Spanned for FunctionArguments

§partial span

The span of FunctionArguments::None is empty.

Source§

impl Spanned for GroupByExpr

§partial span

Missing spans:

Source§

impl Spanned for JoinConstraint

§partial span

Missing spans:

Source§

impl Spanned for JoinOperator

§partial span

Missing spans:

Source§

impl Spanned for JsonPathElem

§partial span

Missing spans:

Source§

impl Spanned for MatchRecognizePattern

§missing span

Source§

impl Spanned for OnConflictAction

§partial span

Missing spans:

Source§

impl Spanned for OnInsert

Source§

impl Spanned for Partition

Source§

impl Spanned for PivotValueSource

Source§

impl Spanned for ReferentialAction

§missing span

Source§

impl Spanned for RenameSelectItem

Source§

impl Spanned for SelectItem

Source§

impl Spanned for SetExpr

§partial span

SetExpr::Table is not implemented.

Source§

impl Spanned for SqlOption

Source§

impl Spanned for Statement

§partial span

Missing spans:

Source§

impl Spanned for Subscript

Source§

impl Spanned for TableConstraint

Source§

impl Spanned for TableFactor

§partial span

Missing spans:

Source§

impl Spanned for TableObject

Source§

impl Spanned for TableOptionsClustered

§partial span

Missing spans:

Source§

impl Spanned for UpdateTableFromKind

Source§

impl Spanned for Use

Source§

impl Spanned for Value

§missing span

The span of a Value is currently not implemented, as doing so requires a breaking changes, which may be done in a future release.

Source§

impl Spanned for Array

Source§

impl Spanned for Assignment

Source§

impl Spanned for ClusteredIndex

Source§

impl Spanned for ColumnDef

Source§

impl Spanned for ColumnOptionDef

Source§

impl Spanned for ConnectBy

Source§

impl Spanned for ConstraintCharacteristics

§missing span

Source§

impl Spanned for CreateIndex

Source§

impl Spanned for CreateTable

Source§

impl Spanned for Cte

Source§

impl Spanned for Delete

Source§

impl Spanned for DoUpdate

Source§

impl Spanned for ExceptSelectItem

Source§

impl Spanned for ExprWithAlias

Source§

impl Spanned for Fetch

Source§

impl Spanned for Function

Source§

impl Spanned for FunctionArgumentList

Source§

impl Spanned for IlikeSelectItem

§missing span

Source§

impl Spanned for Insert

§partial span

Missing spans:ever

Source§

impl Spanned for Interpolate

Source§

impl Spanned for InterpolateExpr

Source§

impl Spanned for Join

Source§

impl Spanned for JsonPath

§partial span

see Spanned impl for JsonPathElem for more information

Source§

impl Spanned for LateralView

Source§

impl Spanned for Measure

Source§

impl Spanned for NamedWindowDefinition

Source§

impl Spanned for ObjectName

Source§

impl Spanned for Offset

Source§

impl Spanned for OnConflict

Source§

impl Spanned for OrderBy

Source§

impl Spanned for OrderByExpr

Source§

impl Spanned for ProjectionSelect

Source§

impl Spanned for Query

Source§

impl Spanned for ReplaceSelectElement

Source§

impl Spanned for ReplaceSelectItem

Source§

impl Spanned for Select

Source§

impl Spanned for SelectInto

Source§

impl Spanned for SymbolDefinition

Source§

impl Spanned for TableAlias

Source§

impl Spanned for TableAliasColumnDef

Source§

impl Spanned for TableWithJoins

Source§

impl Spanned for Values

Source§

impl Spanned for ViewColumnDef

Source§

impl Spanned for WildcardAdditionalOptions

Source§

impl Spanned for With

Source§

impl Spanned for WithFill