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 IndexedColumn
- type SelectStmt
- type SortOrder
- type TableConstraint
- type TableForeignKey
- type TablePrimaryKey
- type TableUnique
- type Trigger
- type TriggerAction
- type TriggerOnDelete
- type TriggerOnUpdate
Constants ¶
const ACTION = 57346
const AND = 57347
const ASC = 57348
const AUTOINCREMENT = 57349
const CASCADE = 57350
const COLLATE = 57351
const CONSTRAINT = 57352
const CREATE = 57353
const DEFAULT = 57354
const DEFERRABLE = 57355
const DEFERRED = 57356
const DELETE = 57357
const DESC = 57358
const FOREIGN = 57359
const FROM = 57360
const GLOB = 57361
const IN = 57362
const INDEX = 57363
const INITIALLY = 57364
const IS = 57365
const KEY = 57366
const LIKE = 57367
const MATCH = 57368
const NO = 57369
const NOT = 57370
const NULL = 57371
const ON = 57372
const OR = 57373
const PRIMARY = 57374
const REFERENCES = 57375
const REGEXP = 57376
const RESTRICT = 57377
const ROWID = 57378
const SELECT = 57379
const SET = 57380
const TABLE = 57381
const UNIQUE = 57382
const UPDATE = 57383
const WHERE = 57384
const WITHOUT = 57385
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
}
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 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 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