sql_ast

package module
v0.0.0-...-1687933 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2021 License: GPL-3.0 Imports: 5 Imported by: 1

README

sql-ast

SQL abstract syntax tree constructors helpers

Documentation

Index

Constants

View Source
const (
	TargetNone SqlTarget = iota
	TargetSchema
	TargetTable
	TargetColumn
	TargetDomain
	TargetType
	TargetConstraint

	RuleNoAction OnDeleteUpdateRule = iota
	RuleCascade
	RuleRestrict
	RuleSetNull
	RuleSetDefault

	NullableNull    Nullable = true
	NullableNotNull Nullable = false

	SetDropDrop SetDrop = false
	SetDropSet  SetDrop = true
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddExpr

type AddExpr struct {
	Target     SqlTarget
	Name       SqlIdent
	Definition SqlExpr
}

func (*AddExpr) String

func (c *AddExpr) String() string

type AlterAttributeExpr

type AlterAttributeExpr struct {
	AttributeName string
	AlterExpr     SqlExpr
}

func (*AlterAttributeExpr) String

func (c *AlterAttributeExpr) String() string

type AlterExpr

type AlterExpr struct {
	Target SqlTarget
	Name   SqlIdent
	Alter  SqlExpr
}

func (*AlterExpr) String

func (c *AlterExpr) String() string

type AlterStmt

type AlterStmt struct {
	Target SqlTarget
	Name   SqlIdent
	Alter  SqlExpr
}

func (*AlterStmt) String

func (c *AlterStmt) String() string

type BinaryExpr

type BinaryExpr struct {
	Left  SqlExpr
	Right SqlExpr
	Op    token.Token
}

func (*BinaryExpr) String

func (c *BinaryExpr) String() string

type BracketBlock

type BracketBlock struct {
	Expr      []SqlExpr
	Statement SqlStmt
}

func (*BracketBlock) String

func (c *BracketBlock) String() string

type ConstraintCheckExpr

type ConstraintCheckExpr struct {
	ConstraintCommon
	Expression SqlExpr
	Where      SqlExpr
}

check

func (*ConstraintCheckExpr) ConstraintParams

func (c *ConstraintCheckExpr) ConstraintParams() string

func (*ConstraintCheckExpr) ConstraintString

func (c *ConstraintCheckExpr) ConstraintString() string

type ConstraintCommon

type ConstraintCommon struct {
	InColumn bool
}

type ConstraintDefaultExpr

type ConstraintDefaultExpr struct {
	ConstraintCommon
	Expression SqlExpr
}

default

func (*ConstraintDefaultExpr) ConstraintParams

func (c *ConstraintDefaultExpr) ConstraintParams() string

func (*ConstraintDefaultExpr) ConstraintString

func (c *ConstraintDefaultExpr) ConstraintString() string

type ConstraintExpr

type ConstraintExpr interface {
	ConstraintInterface
	SqlExpr
}

type ConstraintForeignKeyExpr

type ConstraintForeignKeyExpr struct {
	ConstraintCommon
	ToTable  SqlIdent
	ToColumn string
	OnDelete OnDeleteUpdateRule
	OnUpdate OnDeleteUpdateRule
}

foreign key

func (*ConstraintForeignKeyExpr) ConstraintParams

func (c *ConstraintForeignKeyExpr) ConstraintParams() string

func (*ConstraintForeignKeyExpr) ConstraintString

func (c *ConstraintForeignKeyExpr) ConstraintString() string

type ConstraintInterface

type ConstraintInterface interface {
	ConstraintString() string
	ConstraintParams() string
	// contains filtered or unexported methods
}

type ConstraintNullableExpr

type ConstraintNullableExpr struct {
	ConstraintCommon
	Nullable Nullable
}

not null

func (*ConstraintNullableExpr) ConstraintParams

func (c *ConstraintNullableExpr) ConstraintParams() string

func (*ConstraintNullableExpr) ConstraintString

func (c *ConstraintNullableExpr) ConstraintString() string

type ConstraintPrimaryKeyExpr

type ConstraintPrimaryKeyExpr struct {
	ConstraintCommon
}

primary key

func (*ConstraintPrimaryKeyExpr) ConstraintParams

func (c *ConstraintPrimaryKeyExpr) ConstraintParams() string

func (*ConstraintPrimaryKeyExpr) ConstraintString

func (c *ConstraintPrimaryKeyExpr) ConstraintString() string

type ConstraintUniqueExpr

type ConstraintUniqueExpr struct {
	ConstraintCommon
}

unique

func (*ConstraintUniqueExpr) ConstraintParams

func (c *ConstraintUniqueExpr) ConstraintParams() string

func (*ConstraintUniqueExpr) ConstraintString

func (c *ConstraintUniqueExpr) ConstraintString() string

type ConstraintWithColumns

type ConstraintWithColumns struct {
	Columns    []string
	Constraint ConstraintExpr
}

func (*ConstraintWithColumns) ConstraintParams

func (c *ConstraintWithColumns) ConstraintParams() string

func (*ConstraintWithColumns) ConstraintString

func (c *ConstraintWithColumns) ConstraintString() string

func (*ConstraintWithColumns) String

func (c *ConstraintWithColumns) String() string

type CreateStmt

type CreateStmt struct {
	Target SqlTarget
	Name   SqlIdent
	Create SqlExpr
	IfNotX bool
}

func (*CreateStmt) String

func (c *CreateStmt) String() string

type DataTypeExpr

type DataTypeExpr struct {
	DataType  string
	IsArray   bool
	Length    *int
	Precision *int
	Collation *string

} // NotNull and Default - this is not about data type, this is about Constraints

func (*DataTypeExpr) String

func (c *DataTypeExpr) String() string

type Default

type Default struct {
	Default SqlExpr
}

func (*Default) String

func (c *Default) String() string

type Dependencies

type Dependencies []NamedObject

func ExploreDependencies

func ExploreDependencies(stmt SqlStmt) Dependencies

func ExploreResolved

func ExploreResolved(stmt SqlStmt) Dependencies

type DropExpr

type DropExpr struct {
	Target            SqlTarget
	Name              SqlIdent
	IfExists, Cascade bool
}

func (*DropExpr) String

func (c *DropExpr) String() string

type DropStmt

type DropStmt struct {
	Target SqlTarget
	Name   SqlIdent
}

func (*DropStmt) String

func (c *DropStmt) String() string

type EnumDescription

type EnumDescription struct {
	Values []*String
}

func (*EnumDescription) String

func (c *EnumDescription) String() string

type False

type False struct{}

func (*False) String

func (c *False) String() string

type FncCall

type FncCall struct {
	Name SqlIdent
	Args []SqlExpr
}

func (*FncCall) String

func (c *FncCall) String() string

type InsertStmt

type InsertStmt struct {
	Table      TableDesc
	Insert     map[string]SqlExpr
	OnConflict *OnConflict
}

func (*InsertStmt) String

func (c *InsertStmt) String() string

type Integer

type Integer struct {
	X int
}

func (*Integer) String

func (c *Integer) String() string

type Literal

type Literal struct {
	Text string
}

func (*Literal) GetName

func (c *Literal) GetName() string

func (*Literal) String

func (c *Literal) String() string

type NamedConstraintExpr

type NamedConstraintExpr struct {
	Name       SqlIdent
	Constraint ConstraintInterface
}

func (*NamedConstraintExpr) ConstraintParams

func (c *NamedConstraintExpr) ConstraintParams() string

func (*NamedConstraintExpr) ConstraintString

func (c *NamedConstraintExpr) ConstraintString() string

func (*NamedConstraintExpr) String

func (c *NamedConstraintExpr) String() string

type NamedObject

type NamedObject struct {
	Schema string
	Object string
	Field  string
}

type NotNullClause

type NotNullClause struct{}

func (*NotNullClause) String

func (c *NotNullClause) String() string

type Nullable

type Nullable bool

type OnConflict

type OnConflict struct {
	Cause SqlExpr
	Set   []SqlExpr
}

func (*OnConflict) String

func (c *OnConflict) String() string

type OnDeleteUpdateRule

type OnDeleteUpdateRule int

func (OnDeleteUpdateRule) String

func (c OnDeleteUpdateRule) String() string

type RecordDescription

type RecordDescription struct {
	Fields []SqlExpr
}

func (*RecordDescription) String

func (c *RecordDescription) String() string

type SchemaExpr

type SchemaExpr struct {
	SchemaName string
}

func (*SchemaExpr) String

func (c *SchemaExpr) String() string

type SelectStmt

type SelectStmt struct {
	Columns []SqlExpr
	From    TableDesc
	Where   SqlExpr
}

func (*SelectStmt) String

func (c *SelectStmt) String() string

type Selector

type Selector struct {
	Name      string
	Container string
}

func (*Selector) GetName

func (c *Selector) GetName() string

func (*Selector) String

func (c *Selector) String() string

type SetDrop

type SetDrop bool

func (SetDrop) String

func (c SetDrop) String() string

type SetDropExpr

type SetDropExpr struct {
	SetDrop SetDrop
	Expr    SqlExpr
}

func (*SetDropExpr) String

func (c *SetDropExpr) String() string

type SetExpr

type SetExpr struct {
	Set SqlExpr
}

func (*SetExpr) String

func (c *SetExpr) String() string

type SqlExpr

type SqlExpr interface {
	String() string
	// contains filtered or unexported methods
}

type SqlField

type SqlField struct {
	Name        SqlIdent
	Describer   *DataTypeExpr
	Constraints []ConstraintExpr
}

func (*SqlField) String

func (c *SqlField) String() string

type SqlIdent

type SqlIdent interface {
	GetName() string
}

type SqlNullable

type SqlNullable struct {
	Nullable Nullable
}

func (*SqlNullable) String

func (c *SqlNullable) String() string

type SqlRename

type SqlRename struct {
	Target  SqlTarget
	OldName SqlIdent
	NewName SqlIdent
}

func (*SqlRename) String

func (c *SqlRename) String() string

type SqlStmt

type SqlStmt interface {
	String() string
	// contains filtered or unexported methods
}

type SqlTarget

type SqlTarget int

func (SqlTarget) String

func (c SqlTarget) String() string

type String

type String struct {
	X string
}

func (*String) String

func (c *String) String() string

type TableBodyDescriber

type TableBodyDescriber struct {
	Fields      []*SqlField
	Constraints []ConstraintExpr
}

func (*TableBodyDescriber) String

func (c *TableBodyDescriber) String() string

type TableDesc

type TableDesc struct {
	Table SqlIdent
	Alias string
}

type True

type True struct{}

func (*True) String

func (c *True) String() string

type UnaryExpr

type UnaryExpr struct {
	Ident SqlIdent
}

func (*UnaryExpr) String

func (c *UnaryExpr) String() string

type UnnamedConstraintExpr

type UnnamedConstraintExpr struct {
	Constraint ConstraintInterface
}

func (*UnnamedConstraintExpr) ConstraintParams

func (c *UnnamedConstraintExpr) ConstraintParams() string

func (*UnnamedConstraintExpr) ConstraintString

func (c *UnnamedConstraintExpr) ConstraintString() string

func (*UnnamedConstraintExpr) String

func (c *UnnamedConstraintExpr) String() string

type UpdateStmt

type UpdateStmt struct {
	Table TableDesc
	Set   []SqlExpr
	Where SqlExpr
}

func (*UpdateStmt) String

func (c *UpdateStmt) String() string

type WithStmt

type WithStmt struct {
	Name   string
	With   SelectStmt
	Select SelectStmt
}

func (*WithStmt) String

func (c *WithStmt) String() string

type WithoutNameIdent

type WithoutNameIdent struct{}

func (*WithoutNameIdent) GetName

func (c *WithoutNameIdent) GetName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL