sqlparser library Null safety

An sql parser and analyzer for Dart.

Classes

AggregateFunctionInvocation
AnalysisContext
Result of parsing and analyzing an sql statement. Contains the AST with resolved references, information about result columns and errors that were reported during analysis.
AnalysisError
AnalyzeStatementOptions
Options to analyze a sql statement. This can be used if the type of a variable is known from the outside.
AstNode
A node in the abstract syntax tree of an SQL statement.
AstPreparingVisitor
Prepares the AST for further analysis. This visitor
AstVisitor<A, R>
AtSignVariableToken
AvailableColumn
A column that is available in the scope of a statement.
BaseSelectStatement
BeginTransactionStatement
BetweenExpression
$check BETWEEN $lower AND $upper
BinaryExpression
Block
BLOCK = 'BEGIN' < CRUD-STATEMENT ';' > 'END'
BooleanLiteral
BuiltInMathExtension
A math extension providing functions built into sqlite.
CaseExpression
CastExpression
A CAST(<expr> AS <type>) expression.
CheckColumn
CheckTable
CollateConstraint
CollateExpression
ColonNamedVariable
ColonVariableToken
Column
A column that appears in a ResultSet. Has a type and a name.
ColumnConstraint
https://www.sqlite.org/syntax/column-constraint.html
ColumnDefinition
https://www.sqlite.org/syntax/column-def.html
ColumnResolver
Walks the AST and, for each select statement it sees, finds out which columns are returned and which columns are available. For instance, when we have a table "t" with two columns "a" and "b", the select statement "SELECT a FROM t" has one result column but two columns available.
ColumnWithType
A column that has a statically known resolved type.
CommentToken
A comment, either started with -- or with /*.
CommitStatement
CommonTableExpression
CommonTableExpressionColumn
CompoundSelectColumn
The result column of a CompoundSelectStatement.
CompoundSelectPart
CompoundSelectStatement
CreateIndexStatement
CreateTableStatement
A "CREATE TABLE" statement, see https://www.sqlite.org/lang_createtable.html for the individual components.
CreateTriggerStatement
A "CREATE TRIGGER" statement, see https://sqlite.org/lang_createtrigger.html
CreateViewStatement
A "CREATE VIEW" statement, see https://sqlite.org/lang_createview.html
CreateVirtualTableStatement
CreatingStatement
Marker interface for schema statements that create a schematic entity.
CrudStatement
A statement that reads from an existing table structure and has an optional WITH clause.
CustomResultSet
A custom result set that has columns but isn't a table.
DartExpressionPlaceholder
DartInsertablePlaceholder
DartLimitPlaceholder
DartOrderByPlaceholder
DartOrderingTermPlaceholder
DartPlaceholder
An inline Dart component that appears in a compiled sql query. Inline Dart components can be bound with complex expressions at runtime by using drift's Dart API.
DartPlaceholderDefaultValue
Set a default value for a dart placeholder.
DeclaredStatement
A declared statement inside a .drift file. It consists of an identifier, followed by a colon and the query to run.
DeclaredStatementIdentifier
How a statement was declared in a drift file.
Default
DefaultValues
Use DEFAULT VALUES for an insert statement.
DeferrableClause
DeleteStatement
DeleteTarget
DollarSignVariableToken
DoNothing
DoUpdate
DriftDartName
A AS xyz constraint, which is only parsed for drift files.
DriftFile
A parsed .drift file.
DriftSpecificNode
Marker interface for AST nodes that are drift-specific.
DriftTableName
EngineOptions
ExistsExpression
Expression
ExpressionColumn
A column that is created by an expression. For instance, in the select statement "SELECT 1 + 3", there is a column called "1 + 3" of type int.
ExpressionInvocation
Interface for SqlInvocations that are also expressions.
ExpressionResultColumn
ExprFunctionParameters
Extension
Interface for sqlite extensions providing additional functions or module.
ForeignKeyClause
ForeignKeyColumnConstraint
ForeignKeyTableConstraint
FrameBoundary
Defines how many rows before or after a current row should be included in a window.
FrameSpec
Fts5Extension
FunctionExpression
FunctionHandler
Function handlers can be implemented by an Extension to add type analysis for additional function.
FunctionParameters
Marker interface for anything that can be inside the parentheses after a function name.
GeneratedAs
GroupBy
HasFrom
Interfaces for statements that have a FROM clause.
HasPrimarySource
Interfaces for statements that have a primary source table on which they operate. This includes delete, update and insert statements. It also includes the common SelectStatement, but not compound select statements or VALUES statements.
HasWhereClause
Common interface for every node that has a where clause.
HumanReadable
Something that can be represented in a human-readable description.
IdentifierToken
ImportStatement
An import "file.dart"; statement that can appear inside a drift file.
IndexedColumn
Note that this class matches the productions listed at https://www.sqlite.org/syntax/indexed-column.html We don't have a special case for column-name (those are References). The COLLATE branch is covered by parsing a CollateExpression for expression.
InExpression
$left$ IN $inside.
InlineDartToken
Inline Dart appearing in a create table statement. Only parsed when the drift extensions are enabled. Dart code is wrapped in backticks.
InsertSource
Marker interface for AST nodes that can be used as data sources in insert statements.
InsertStatement
InsertTarget
InvalidStatement
Used as a top-level substitute when no statement could be parsed otherwise.
IsBoolean
Type hint to mark that this type will contain a boolean value.
IsDateTime
Type hint to mark that this type will contain a date time value.
IsExpression
(NOT)? $left IS $right
IsNullExpression
Join
JoinClause
https://www.sqlite.org/syntax/join-clause.html
JoinConstraint
https://www.sqlite.org/syntax/join-constraint.html
JoinModel
Tracks table references that must be non-nullable in a query row.
Json1Extension
JsonKey
A JSON KEY xyz constraint, which is only parsed for drift files.
KeyClause
KeywordToken
Used for tokens that are keywords. We use this special class without any additional properties to ease syntax highlighting, as it allows us to find the keywords easily.
Limit
LimitBase
Base for LIMIT clauses. Without drift extensions, only Limit will be parsed. With drift extensions, a DartLimitPlaceholder can be emitted as well.
LintingVisitor
Visitor that runs after all other steps ran and reports more complex lints on an sql statement.
Literal<T>
MappedBy
A MAPPED BY constraint, which is only parsed for drift files. It can be used to declare a type converter for this column.
Module
An sqlite module, which can be used in a CREATE VIRTUAL TABLE statement to find providers.
NamedResultSet
Something that returns a set of Columns and can be referenced by a name, such as a table or a view.
NamedWindowDeclaration
A window declaration that appears in a SELECT statement like WINDOW <name> AS <window-defn>. It can be referenced from an AggregateFunctionInvocation if it uses the same name.
NestedQueryColumn
A nested query column, denoted by LIST(...) in user queries.
NestedStarResultColumn
A nested star result column, denoted by ** in user queries.
NotNull
NullColumnConstraint
NullLiteral<T>
NumberedVariable
A "?" or "?123" variable placeholder
NumericLiteral
NumericToken
Used to represent additional information of TokenType.numberLiteral.
OnConstraint
OrderBy
OrderByBase
Base for ORDER BY clauses. Without drift extensions, ony OrderBy will be parsed. Otherwise, DartOrderByPlaceholder can be parsed as well.
OrderingTerm
OrderingTermBase
Base for a single ordering term that is a part of a OrderBy. Without drift extensions, only OrderingTerm will be parsed. With drift extensions, a DartOrderingTermPlaceholder can be parsed as well.
Parentheses
ParseResult
The result of parsing an sql query. Contains the root of the AST and all errors that might have occurred during parsing.
PartOfDriftFile
Something that can appear as a top-level declaration inside a .drift file.
PrimaryKeyColumn
Queryable
Marker interface for something that can appear after a "FROM" in a select statement.
QuestionMarkVariableToken
RaiseExpression
RecursiveVisitor<A, R>
Visitor that walks down the entire tree, visiting all children in order.
Reference
Expression that refers to an individual expression declared somewhere else in the table.
ReferenceExpressionColumn
A column that is created by a reference expression. The difference to an ExpressionColumn is that the correct case of the column name depends on the resolved reference.
ReferenceResolver
Resolves any open Reference it finds in the AST.
ReferenceScope
Class which keeps track of references for tables, columns and functions in a query.
Renamable
ResolvedType
ResolveResult
Result of resolving a type. This can either have the resolved type set, or it can inform the called that it needsContext to resolve the type properly. Failure to resolve the type will have the unknown flag set.
ResolvesToResultSet
Something that will resolve to an ResultSet when referred to via the ReferenceScope.
ResultColumn
ResultSet
Something that returns a set of columns when evaluated.
ResultSetAvailableInStatement
Information about a result set that is available in a statement.
Returning
A returning clause describes expressions to evaluate after an insert, an update or a delete statement.
RowId
Refers to the special "rowid", "oid" or "rowid" column defined for tables that weren't created with an WITHOUT ROWID clause.
SchemaFromCreateTable
Reads the Table definition from a CreateTableStatement.
SchemaStatement
Marker interface for statements that change the table structure.
SelectInsertSource
Inserts the rows returned by stmt.
SelectStatement
SelectStatementAsSource
A nested select statement that appears after a FROM clause. This is different from nested select expressions, which can only return one value.
SelectStatementNoCompound
Marker interface for classes that are a BaseSelectStatement but aren't a CompoundSelectStatement.
SetComponent
SetParentVisitor
Sets the AstNode.parent property for each node in a tree.
SimpleName
The normal, named statement identifier for regular statements.
SpecialStatementIdentifier
A special statement identifier for statements declared with a @-name.
SqlEngine
SqlInvocation
Interface for function calls.
SqliteVersion
The assumed version of sqlite3.
StarFunctionParameter
Using a star as a function parameter. For instance: "COUNT(*)".
StarResultColumn
A result column that either yields all columns or all columns from a table by using "" or "table.".
Statement
StatementParameter
A statement parameter, which appears between brackets after the statement identifier. In selectString(:name AS TEXT): SELECT :name, :name AS TEXT is a statement parameter.
StatementReturningColumns
Interface for statements that can return columns after writing data.
StatementWithWhere
Interface for statements that have a primary where clause (select, update, delete).
StringComparisonExpression
A like, glob, match or regexp expression.
StringLiteral
StringLiteralToken
SubQuery
A subquery, which is an expression. It is expected that the inner query only returns one column and one row.
SyntacticEntity
Interface for entities that appear in a piece of text. As far as the parser is concerned, this contains tokens and ast nodes.
Table
A database table. The information stored here will be used to resolve references and for type inference.
TableAlias
TableColumn
A column that is part of a table.
TableConstraint
TableInducingStatement
TableOrSubquery
https://www.sqlite.org/syntax/table-or-subquery.html Marker interface
TableReference
A table. The first path in https://www.sqlite.org/syntax/table-or-subquery.html
TableValuedFunction
TableValuedFunctionHandler
Interface for a handler which can resolve the result set of a table-valued function.
TimeConstantLiteral
Token
TokenizerError
TransactionBlock
Transformer<A>
TriggerTarget
Tuple
A tuple of values, denotes in brackets. (<expr>, ..., <expr>).
Typeable
Something that has a type.
TypeHint
Provides more precise hints than the BasicType. For instance, booleans are stored as ints in sqlite, but it might be desirable to know whether an expression will actually be a boolean, so we could set the ResolvedType.hint to IsBoolean.
TypeInferenceResults
Apis to view results of a type inference session.
UnaryExpression
UniqueColumn
UnresolvedReferenceError
UpdateStatement
UpdateTarget
UpsertAction
UpsertClause
UpsertClauseEntry
UsingConstraint
ValuesSelectColumn
Result column coming from a VALUES select statement.
ValuesSelectStatement
A select statement of the form VALUES (expr-list), ..., (expr-list-N).
ValuesSource
Uses a list of values for an insert statement (VALUES (a, b, c)).
Variable
VariableToken
VariableTypeHint
Construct to explicitly set a variable type.
View
A database view. The information stored here will be used to resolve references and for type inference.
ViewColumn
A column that is part of a view.
WhenComponent
WindowDefinition
WindowFunctionInvocation
WithClause

Mixins

ArgumentCountLinter
Should be mixed on on FunctionHandler implementations only.
DelegatedColumn
A column that wraps another column.
Referencable
Mixin for classes which can be referenced by a ReferenceOwner.
ReferenceOwner
Mixin for classes which represent a reference.

Extensions

ExpandParameters
Extension to expand parameters defined in a sql invocation, which is either a FunctionExpression or an AggregateFunctionInvocation.
SyntacticLengthExtension
Extension to report the length of a SyntacticEntity.
TransformerUtils
UnaliasColumn
UnaliasResultSet
UnionEntityExtension
Extension to obtain the span for a sequence of SyntacticEntity.
VisitChildrenExtension
VisitExtension

Constants

aliasesForRowId → const List<String>
The aliases which can be used to refer to the rowid of a table. See https://www.sqlite.org/lang_createtable.html#rowid
['rowid', 'oid', '_rowid_']
postgresKeywords → const Map<String, TokenType>
{'ANY' : TokenType.any, 'ARRAY' : TokenType.array, 'ASYMMETRIC' : TokenType.asymmetric, 'BINARY' : TokenType.binary, 'BOTH' : TokenType.both, 'CURRENT_USER&…

Properties

reverseKeywords Map<TokenType, String>
Maps TokenTypes which are keywords to their lexeme.
final

Functions

isKeywordLexeme(String name) bool
Returns true if name is a reserved keyword in sqlite.
isPostgresKeywordLexeme(String name) bool
Returns true if name is a reserved keyword in postgres.

Enums

AnalysisErrorType
BasicType
A type that sql expressions can have at runtime.
CommentMode
CompoundSelectMode
ConflictClause
ExcludeMode
Defines if rows are omitted inside a FrameBoundary.
FailureMode
FrameType
Defines how a FrameBoundary count rows or groups. See https://www.sqlite.org/windowfunctions.html#frame_type for details.
InitialDeferrableMode
InsertMode
JoinOperator
MaterializationHint
OrderingBehaviorForNulls
OrderingMode
RaiseKind
ReferenceAction
TimeConstantKind
TokenType
TransactionMode
TriggerMode

Exceptions / Errors

CantReadSchemaException
Thrown when a table schema could not be read.
CumulatedTokenizerException
Thrown by the sql engine when a sql statement can't be tokenized.
ParsingError