Documentation
¶
Overview ¶
Package sql is a parser for the subset of SQL needed for SQLite's `CREATE TABLE` and `CREATE INDEX` statements.
It deals with most of https://sqlite.org/lang_createtable.html and https://sqlite.org/lang_createindex.html
It is used by sqlittle to read the table and index definitions embedded in `.sqlite` files.
Index ¶
- Constants
- func AsColumn(e Expression) string
- func AsString(e Expression) string
- func Parse(sql string) (interface{}, error)
- type ColumnDef
- type CreateIndexStmt
- type CreateTableStmt
- type ExBinaryOp
- type ExColumn
- type ExFunction
- type Expression
- type ForeignKeyClause
- type IndexedColumn
- type SelectStmt
- type SortOrder
- type TableConstraint
- type TableForeignKey
- type TablePrimaryKey
- type TableUnique
- type Trigger
- type TriggerAction
- type TriggerOnDelete
- type TriggerOnUpdate
Constants ¶
const ABORT = 57346
const ACTION = 57347
const AND = 57348
const ASC = 57349
const AUTOINCREMENT = 57350
const CASCADE = 57351
const CHECK = 57352
const COLLATE = 57353
const CONFLICT = 57354
const CONSTRAINT = 57355
const CREATE = 57356
const DEFAULT = 57357
const DEFERRABLE = 57358
const DEFERRED = 57359
const DELETE = 57360
const DESC = 57361
const FAIL = 57362
const FOREIGN = 57363
const FROM = 57364
const GLOB = 57365
const IGNORE = 57366
const IN = 57367
const INDEX = 57368
const INITIALLY = 57369
const IS = 57370
const KEY = 57371
const LIKE = 57372
const MATCH = 57373
const NO = 57374
const NOT = 57375
const NULL = 57376
const ON = 57377
const OR = 57378
const PRIMARY = 57379
const REFERENCES = 57380
const REGEXP = 57381
const REPLACE = 57382
const RESTRICT = 57383
const ROLLBACK = 57384
const ROWID = 57385
const SELECT = 57386
const SET = 57387
const TABLE = 57388
const UNIQUE = 57389
const UPDATE = 57390
const WHERE = 57391
const WITHOUT = 57392
Variables ¶
This section is empty.
Functions ¶
func AsColumn ¶
func AsColumn(e Expression) string
gives the column name if the expression is a simple single column
func AsString ¶
func AsString(e Expression) string
Types ¶
type ColumnDef ¶
type ColumnDef struct { Name string Type string PrimaryKey bool PrimaryKeyDir SortOrder AutoIncrement bool Null bool Unique bool Default interface{} Collate string References *ForeignKeyClause Checks []Expression }
Definition of a column, as found by CreateTableStmt
type CreateIndexStmt ¶
type CreateIndexStmt struct { Index string Table string Unique bool IndexedColumns []IndexedColumn Where Expression }
A `CREATE INDEX` statement
type CreateTableStmt ¶
type CreateTableStmt struct { Table string Columns []ColumnDef Constraints []TableConstraint WithoutRowid bool }
A `CREATE TABLE` statement
type ExBinaryOp ¶
type ExBinaryOp struct { Op string Left, Right Expression }
type ExFunction ¶
type ExFunction struct { F string Args []Expression }
type Expression ¶
type Expression interface{}
type ForeignKeyClause ¶ added in v1.3.4
type IndexedColumn ¶
Indexed column, for CreateIndexStmt, and index table constraints. Either Column or Expression is filled. Column is filled if the expression is a single column (as is always the case for PRIMARY KEY and UNIQUE constraints), and Expression is filled in every other case.
type TableConstraint ¶
type TableConstraint interface{}
CREATE TABLE constraint (primary key, index)
type TableForeignKey ¶
type TableForeignKey struct { Columns []string Clause ForeignKeyClause }
type TablePrimaryKey ¶
type TablePrimaryKey struct {
IndexedColumns []IndexedColumn
}
type TableUnique ¶
type TableUnique struct {
IndexedColumns []IndexedColumn
}
type TriggerAction ¶
type TriggerAction int
const ( ActionSetNull TriggerAction = iota ActionSetDefault ActionCascade ActionRestrict ActionNoAction )
type TriggerOnDelete ¶
type TriggerOnDelete TriggerAction
type TriggerOnUpdate ¶
type TriggerOnUpdate TriggerAction