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 ABORT = 57346
const ACTION = 57347
const AND = 57348
const ASC = 57349
const AUTOINCREMENT = 57350
const CASCADE = 57351
const COLLATE = 57352
const CONFLICT = 57353
const CONSTRAINT = 57354
const CREATE = 57355
const DEFAULT = 57356
const DEFERRABLE = 57357
const DEFERRED = 57358
const DELETE = 57359
const DESC = 57360
const FAIL = 57361
const FOREIGN = 57362
const FROM = 57363
const GLOB = 57364
const IGNORE = 57365
const IN = 57366
const INDEX = 57367
const INITIALLY = 57368
const IS = 57369
const KEY = 57370
const LIKE = 57371
const MATCH = 57372
const NO = 57373
const NOT = 57374
const NULL = 57375
const ON = 57376
const OR = 57377
const PRIMARY = 57378
const REFERENCES = 57379
const REGEXP = 57380
const REPLACE = 57381
const RESTRICT = 57382
const ROLLBACK = 57383
const ROWID = 57384
const SELECT = 57385
const SET = 57386
const TABLE = 57387
const UNIQUE = 57388
const UPDATE = 57389
const WHERE = 57390
const WITHOUT = 57391
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