rel

package
v0.0.0-...-77bcb31 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package rel are the AST Structures and Parsers for the SQL, FilterQL, and Expression dialects.

Package rel is a generated protocol buffer package.

It is generated from these files:
	sql.proto

It has these top-level messages:
	SqlStatementPb
	SqlSelectPb
	SqlSourcePb
	SqlWherePb
	ProjectionPb
	ResultColumnPb
	KvInt
	ColumnPb
	CommandColumnPb

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthSql = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowSql   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	// SqlKeywords the SqlKeywords list
	SqlKeywords = []string{"select", "insert", "update", "delete", "from", "where", "as", "into", "limit",
		"exists", "in", "contains", "include", "not", "and", "having", "or", "null", "group", "order",
		"offset", "include", "all", "any", "some"}
)

Functions

func EqualWith

func EqualWith(l, r u.JsonHelper) bool

EqualWith compare two with helpers for equality.

func HelperString

func HelperString(w expr.DialectWriter, jh u.JsonHelper)

HelperString Convert a Helper into key/value string

func MapIntFromPb

func MapIntFromPb(kv []KvInt) map[string]int

func NewSqlDialect

func NewSqlDialect() expr.DialectWriter

func ParseJsonArray

func ParseJsonArray(pg expr.TokenPager) ([]interface{}, error)

func ParseJsonObject

func ParseJsonObject(pg expr.TokenPager, jh u.JsonHelper) error

func ParseKeyValue

func ParseKeyValue(pg expr.TokenPager, jh u.JsonHelper) error

func ParseWith

func ParseWith(pg expr.TokenPager) (u.JsonHelper, error)

func RewriteSelect

func RewriteSelect(m *SqlSelect)

RewriteSelect We are removing Column Aliases "user_id as uid" as well as functions - used when we are going to defer projection, aggs

Types

type Column

type Column struct {
	ParentIndex    int       // slice idx position in parent query cols
	Index          int       // slice idx position in original query cols
	SourceIndex    int       // slice idx position in source []driver.Value
	SourceField    string    // field name of underlying field
	SourceOriginal string    // field name of underlying field without the "left.right" parse
	As             string    // As field, auto-populate the Field Name if exists
	Comment        string    // optional in-line comments
	Order          string    // (ASC | DESC)
	Star           bool      // *
	Agg            bool      // aggregate function column?   count(*), avg(x) etc
	Expr           expr.Node // Expression, optional, often Identity.Node
	Guard          expr.Node // column If guard, non-standard sql column guard
	// contains filtered or unexported fields
}

Column represents the Column as expressed in a [SELECT] expression

func NewColumn

func NewColumn(col string) *Column

func NewColumnFromToken

func NewColumnFromToken(tok lex.Token) *Column

func NewColumnValue

func NewColumnValue(tok lex.Token) *Column

func (*Column) Asc

func (m *Column) Asc() bool

func (*Column) Copy

func (m *Column) Copy() *Column

Copy - deep copy, shared nothing

func (*Column) CopyRewrite

func (m *Column) CopyRewrite(alias string) *Column

CopyRewrite Create a new copy of this column for rewrite purposes removing alias

func (*Column) CountStar

func (m *Column) CountStar() bool

Is this a select count(*) column

func (*Column) Equal

func (m *Column) Equal(c *Column) bool

func (*Column) InFinalProjection

func (m *Column) InFinalProjection() bool

func (*Column) IsLiteral

func (m *Column) IsLiteral() bool

func (*Column) IsLiteralOrFunc

func (m *Column) IsLiteralOrFunc() bool

func (*Column) Key

func (m *Column) Key() string

func (*Column) LeftRight

func (m *Column) LeftRight() (string, string, bool)

Return left, right values if is of form `table.column` and also return true/false for if it even has left/right

func (*Column) String

func (m *Column) String() string

func (*Column) ToPB

func (m *Column) ToPB() *ColumnPb

func (*Column) WriteDialect

func (m *Column) WriteDialect(w expr.DialectWriter)

type ColumnPb

type ColumnPb struct {
	SourceQuote      []byte       `protobuf:"bytes,1,opt,name=sourceQuote" json:"sourceQuote,omitempty"`
	AsQuoteByte      []byte       `protobuf:"bytes,2,opt,name=asQuoteByte" json:"asQuoteByte,omitempty"`
	OriginalAs       *string      `protobuf:"bytes,3,opt,name=originalAs" json:"originalAs,omitempty"`
	Left             *string      `protobuf:"bytes,4,opt,name=left" json:"left,omitempty"`
	Right            *string      `protobuf:"bytes,5,opt,name=right" json:"right,omitempty"`
	ParentIndex      int32        `protobuf:"varint,6,opt,name=parentIndex" json:"parentIndex"`
	Index            int32        `protobuf:"varint,7,opt,name=index" json:"index"`
	SourceIndex      int32        `protobuf:"varint,8,opt,name=sourceIndex" json:"sourceIndex"`
	SourceField      *string      `protobuf:"bytes,9,opt,name=sourceField" json:"sourceField,omitempty"`
	As               string       `protobuf:"bytes,11,opt,name=as" json:"as"`
	Comment          *string      `protobuf:"bytes,12,opt,name=comment" json:"comment,omitempty"`
	Order            *string      `protobuf:"bytes,13,opt,name=order" json:"order,omitempty"`
	Star             *bool        `protobuf:"varint,14,opt,name=star" json:"star,omitempty"`
	Agg              bool         `protobuf:"varint,15,opt,name=agg" json:"agg"`
	Expr             *expr.NodePb `protobuf:"bytes,16,opt,name=Expr,json=expr" json:"Expr,omitempty"`
	Guard            *expr.NodePb `protobuf:"bytes,17,opt,name=Guard,json=guard" json:"Guard,omitempty"`
	XXX_unrecognized []byte       `json:"-"`
}

func ColumnsToPb

func ColumnsToPb(c Columns) []*ColumnPb

func (*ColumnPb) Descriptor

func (*ColumnPb) Descriptor() ([]byte, []int)

func (*ColumnPb) GetAgg

func (m *ColumnPb) GetAgg() bool

func (*ColumnPb) GetAs

func (m *ColumnPb) GetAs() string

func (*ColumnPb) GetAsQuoteByte

func (m *ColumnPb) GetAsQuoteByte() []byte

func (*ColumnPb) GetComment

func (m *ColumnPb) GetComment() string

func (*ColumnPb) GetExpr

func (m *ColumnPb) GetExpr() *expr.NodePb

func (*ColumnPb) GetGuard

func (m *ColumnPb) GetGuard() *expr.NodePb

func (*ColumnPb) GetIndex

func (m *ColumnPb) GetIndex() int32

func (*ColumnPb) GetLeft

func (m *ColumnPb) GetLeft() string

func (*ColumnPb) GetOrder

func (m *ColumnPb) GetOrder() string

func (*ColumnPb) GetOriginalAs

func (m *ColumnPb) GetOriginalAs() string

func (*ColumnPb) GetParentIndex

func (m *ColumnPb) GetParentIndex() int32

func (*ColumnPb) GetRight

func (m *ColumnPb) GetRight() string

func (*ColumnPb) GetSourceField

func (m *ColumnPb) GetSourceField() string

func (*ColumnPb) GetSourceIndex

func (m *ColumnPb) GetSourceIndex() int32

func (*ColumnPb) GetSourceQuote

func (m *ColumnPb) GetSourceQuote() []byte

func (*ColumnPb) GetStar

func (m *ColumnPb) GetStar() bool

func (*ColumnPb) Marshal

func (m *ColumnPb) Marshal() (data []byte, err error)

func (*ColumnPb) MarshalTo

func (m *ColumnPb) MarshalTo(data []byte) (int, error)

func (*ColumnPb) ProtoMessage

func (*ColumnPb) ProtoMessage()

func (*ColumnPb) Reset

func (m *ColumnPb) Reset()

func (*ColumnPb) Size

func (m *ColumnPb) Size() (n int)

func (*ColumnPb) String

func (m *ColumnPb) String() string

func (*ColumnPb) Unmarshal

func (m *ColumnPb) Unmarshal(data []byte) error

type Columns

type Columns []*Column

Columns List of Columns in SELECT [columns]

func ColumnsFromPb

func ColumnsFromPb(c []*ColumnPb) Columns

func (*Columns) AliasedFieldNames

func (m *Columns) AliasedFieldNames() []string

func (*Columns) ByAs

func (m *Columns) ByAs(as string) (*Column, bool)

func (*Columns) ByName

func (m *Columns) ByName(name string) (*Column, bool)

func (Columns) Equal

func (m Columns) Equal(cols Columns) bool

func (*Columns) FieldNames

func (m *Columns) FieldNames() []string

func (*Columns) String

func (m *Columns) String() string

func (*Columns) UnAliasedFieldNames

func (m *Columns) UnAliasedFieldNames() []string

func (*Columns) WriteDialect

func (m *Columns) WriteDialect(w expr.DialectWriter)

type ColumnsStatement

type ColumnsStatement interface {
	AddColumn(col Column) error
}

ColumnsStatement is a statement interface for those statements that have columns that need to be added during parse.

type CommandColumn

type CommandColumn struct {
	Expr expr.Node // column expression
	Name string    // Original path/name for command field
}

CommandColumn is single column such as "autocommit"

func (*CommandColumn) FingerPrint

func (m *CommandColumn) FingerPrint(r rune) string

func (*CommandColumn) Key

func (m *CommandColumn) Key() string

func (*CommandColumn) String

func (m *CommandColumn) String() string

func (*CommandColumn) WriteDialect

func (m *CommandColumn) WriteDialect(w expr.DialectWriter)

type CommandColumnPb

type CommandColumnPb struct {
	Expr             *expr.NodePb `protobuf:"bytes,1,opt,name=Expr,json=expr" json:"Expr,omitempty"`
	Name             string       `protobuf:"bytes,2,req,name=name" json:"name"`
	XXX_unrecognized []byte       `json:"-"`
}

func (*CommandColumnPb) Descriptor

func (*CommandColumnPb) Descriptor() ([]byte, []int)

func (*CommandColumnPb) GetExpr

func (m *CommandColumnPb) GetExpr() *expr.NodePb

func (*CommandColumnPb) GetName

func (m *CommandColumnPb) GetName() string

func (*CommandColumnPb) Marshal

func (m *CommandColumnPb) Marshal() (data []byte, err error)

func (*CommandColumnPb) MarshalTo

func (m *CommandColumnPb) MarshalTo(data []byte) (int, error)

func (*CommandColumnPb) ProtoMessage

func (*CommandColumnPb) ProtoMessage()

func (*CommandColumnPb) Reset

func (m *CommandColumnPb) Reset()

func (*CommandColumnPb) Size

func (m *CommandColumnPb) Size() (n int)

func (*CommandColumnPb) String

func (m *CommandColumnPb) String() string

func (*CommandColumnPb) Unmarshal

func (m *CommandColumnPb) Unmarshal(data []byte) error

type CommandColumns

type CommandColumns []*CommandColumn

CommandColumns SQL commands such as:

set autocommit
SET @@local.sort_buffer_size=10000;
USE myschema;

func (*CommandColumns) String

func (m *CommandColumns) String() string

func (*CommandColumns) WriteDialect

func (m *CommandColumns) WriteDialect(w expr.DialectWriter)

type DdlColumn

type DdlColumn struct {
	Kw            lex.TokenType // initial keyword (identity for normal, constraint, primary)
	Null          bool          // Do we support NULL?
	AutoIncrement bool          // auto increment
	IndexType     string        // index_type
	IndexCols     []string      // index_col_name
	RefTable      string        // refererence table
	RefCols       []string      // ref cols
	Default       expr.Node     // Default value
	DataType      string        // data type
	DataTypeSize  int           // Data Type Size:    varchar(2000)
	DataTypeArgs  []expr.Node   // data type args
	Key           lex.TokenType // UNIQUE | PRIMARY
	Name          string        // name
	Comment       string        // optional in-line comments
	Expr          expr.Node     // Expression, optional, often Identity.Node but could be composite key
}

DdlColumn represents the Data Definition Column

type Filter

type Filter interface {
	String() string
}

Filter interface for Filter Statements (either Filter/FilterSelect)

type FilterQLParser

type FilterQLParser struct {
	// contains filtered or unexported fields
}

FilterQLParser

func NewFilterParser

func NewFilterParser(filter string) *FilterQLParser

func NewFilterParserfuncs

func NewFilterParserfuncs(filter string, funcs expr.FuncResolver) *FilterQLParser

func (FilterQLParser) ClauseEnd

func (m FilterQLParser) ClauseEnd() bool

func (*FilterQLParser) FuncResolver

func (f *FilterQLParser) FuncResolver(funcs expr.FuncResolver) *FilterQLParser

FuncResolver sets the function resolver to use during parsing. By default we only use the Global resolver. But if you set a function resolver we'll use that first and then fall back to the Global resolver.

func (FilterQLParser) IsEnd

func (m FilterQLParser) IsEnd() bool

func (*FilterQLParser) ParseFilter

func (f *FilterQLParser) ParseFilter() (*FilterSelect, error)

ParseFilterQL Parses a FilterQL statement

func (*FilterQLParser) ParseFilterSelects

func (f *FilterQLParser) ParseFilterSelects() (stmts []*FilterSelect, err error)

func (*FilterQLParser) ParseFilters

func (f *FilterQLParser) ParseFilters() (stmts []*FilterStatement, err error)

type FilterSelect

type FilterSelect struct {
	*FilterStatement
	Columns Columns
}

FilterSelect is a Filter but also has projected columns

func NewFilterSelect

func NewFilterSelect() *FilterSelect

func ParseFilterSelect

func ParseFilterSelect(query string) (*FilterSelect, error)

ParseFilterSelect Parse a single Select-Filter statement from text Select-Filters are statements of following form

"SELECT" [COLUMNS] (FILTER | WHERE) FilterExpression
"FILTER" FilterExpression

func ParseFilterSelects

func ParseFilterSelects(statement string) (stmts []*FilterSelect, err error)

ParseFilterSelects Parse 1-n Select-Filter statements from text Select-Filters are statements of following form

"SELECT" [COLUMNS] (FILTER | WHERE) FilterExpression
"FILTER" FilterExpression

func (*FilterSelect) AddColumn

func (m *FilterSelect) AddColumn(colArg Column) error

func (*FilterSelect) Equal

func (m *FilterSelect) Equal(s *FilterSelect) bool

Equal Checks for deep equality

func (*FilterSelect) FingerPrintID

func (m *FilterSelect) FingerPrintID() int64

FingerPrint consistent hashed int value of FingerPrint above

func (*FilterSelect) String

func (m *FilterSelect) String() string

String representation of FilterSelect

func (*FilterSelect) WriteDialect

func (m *FilterSelect) WriteDialect(w expr.DialectWriter)

type FilterStatement

type FilterStatement struct {
	Description string       // initial pre-start comments
	Raw         string       // full original raw statement
	Filter      expr.Node    // FILTER <filter_expr>
	Where       expr.Node    // WHERE <expr> [AND <expr>] syntax
	OrderBy     Columns      // order by
	From        string       // From is optional
	Limit       int          // Limit
	Alias       string       // Non-Standard sql, alias/name of sql another way of expression Prepared Statement
	With        u.JsonHelper // Non-Standard SQL for properties/config info, similar to Cassandra with, purse json
	// contains filtered or unexported fields
}

FilterStatement is a statement of type = Filter

func MustParseFilter

func MustParseFilter(statement string) *FilterStatement

func MustParseFilters

func MustParseFilters(statement string) []*FilterStatement

func NewFilterStatement

func NewFilterStatement() *FilterStatement

NewFilterStatement Create A FilterStatement

func ParseFilterQL

func ParseFilterQL(filter string) (*FilterStatement, error)

ParseFilterQL Parses a FilterQL statement

func ParseFilters

func ParseFilters(statement string) (stmts []*FilterStatement, err error)

ParseFilters Parse a list of Filter statement's from text

func (*FilterStatement) Equal

func (m *FilterStatement) Equal(s *FilterStatement) bool

func (*FilterStatement) FingerPrintID

func (m *FilterStatement) FingerPrintID() int64

FingerPrint consistent hashed int value of FingerPrint above

func (*FilterStatement) Includes

func (m *FilterStatement) Includes() []string

Includes Recurse this statement and find all includes

func (*FilterStatement) String

func (m *FilterStatement) String() string

String representation of FilterStatement

func (*FilterStatement) WriteDialect

func (m *FilterStatement) WriteDialect(w expr.DialectWriter)

type KvInt

type KvInt struct {
	K                string `protobuf:"bytes,1,req,name=k" json:"k"`
	V                int32  `protobuf:"varint,2,req,name=v" json:"v"`
	XXX_unrecognized []byte `json:"-"`
}

func (*KvInt) Descriptor

func (*KvInt) Descriptor() ([]byte, []int)

func (*KvInt) GetK

func (m *KvInt) GetK() string

func (*KvInt) GetV

func (m *KvInt) GetV() int32

func (*KvInt) Marshal

func (m *KvInt) Marshal() (data []byte, err error)

func (*KvInt) MarshalTo

func (m *KvInt) MarshalTo(data []byte) (int, error)

func (*KvInt) ProtoMessage

func (*KvInt) ProtoMessage()

func (*KvInt) Reset

func (m *KvInt) Reset()

func (*KvInt) Size

func (m *KvInt) Size() (n int)

func (*KvInt) String

func (m *KvInt) String() string

func (*KvInt) Unmarshal

func (m *KvInt) Unmarshal(data []byte) error

type ParseError

type ParseError struct {
	// contains filtered or unexported fields
}

ParseError type

type PreparedStatement

type PreparedStatement struct {
	Alias     string
	Statement SqlStatement
}

PreparedStatement Prepared/Aliased SQL statement

func NewPreparedStatement

func NewPreparedStatement() *PreparedStatement

func (*PreparedStatement) Keyword

func (m *PreparedStatement) Keyword() lex.TokenType

func (*PreparedStatement) String

func (m *PreparedStatement) String() string

func (*PreparedStatement) WriteDialect

func (m *PreparedStatement) WriteDialect(w expr.DialectWriter)

type Projection

type Projection struct {
	Distinct bool
	Final    bool // Is this a Final Projection? or intermiediate?

	Columns ResultColumns
	// contains filtered or unexported fields
}

Projection describes the results to expect from sql statement ie the ResultColumns for a result-set

func NewProjection

func NewProjection() *Projection

func ProjectionFromPb

func ProjectionFromPb(pb *ProjectionPb) *Projection

func (*Projection) AddColumn

func (m *Projection) AddColumn(col *Column, vt value.ValueType)

func (*Projection) AddColumnShort

func (m *Projection) AddColumnShort(colName string, vt value.ValueType)

func (*Projection) Equal

func (m *Projection) Equal(s *Projection) bool

func (*Projection) FromPB

func (m *Projection) FromPB(pb *ProjectionPb) *Projection

func (*Projection) ToPB

func (m *Projection) ToPB() *ProjectionPb

type ProjectionPb

type ProjectionPb struct {
	Distinct         bool              `protobuf:"varint,1,req,name=distinct" json:"distinct"`
	Final            bool              `protobuf:"varint,2,req,name=final" json:"final"`
	ColNames         []string          `protobuf:"bytes,3,rep,name=colNames" json:"colNames,omitempty"`
	Columns          []*ResultColumnPb `protobuf:"bytes,4,rep,name=columns" json:"columns,omitempty"`
	XXX_unrecognized []byte            `json:"-"`
}

func (*ProjectionPb) Descriptor

func (*ProjectionPb) Descriptor() ([]byte, []int)

func (*ProjectionPb) GetColNames

func (m *ProjectionPb) GetColNames() []string

func (*ProjectionPb) GetColumns

func (m *ProjectionPb) GetColumns() []*ResultColumnPb

func (*ProjectionPb) GetDistinct

func (m *ProjectionPb) GetDistinct() bool

func (*ProjectionPb) GetFinal

func (m *ProjectionPb) GetFinal() bool

func (*ProjectionPb) Marshal

func (m *ProjectionPb) Marshal() (data []byte, err error)

func (*ProjectionPb) MarshalTo

func (m *ProjectionPb) MarshalTo(data []byte) (int, error)

func (*ProjectionPb) ProtoMessage

func (*ProjectionPb) ProtoMessage()

func (*ProjectionPb) Reset

func (m *ProjectionPb) Reset()

func (*ProjectionPb) Size

func (m *ProjectionPb) Size() (n int)

func (*ProjectionPb) String

func (m *ProjectionPb) String() string

func (*ProjectionPb) Unmarshal

func (m *ProjectionPb) Unmarshal(data []byte) error

type ResultColumn

type ResultColumn struct {
	Final  bool            // Is this part of final projection (ie, response)
	Name   string          // Original path/name for query field
	ColPos int             // Ordinal position in sql (or partial sql) statement
	Col    *Column         // the original sql column
	Star   bool            // Was this a select * ??
	As     string          // aliased
	Type   value.ValueType // Data Type
}

Result Column used in projection

func NewResultColumn

func NewResultColumn(as string, ordinal int, col *Column, valtype value.ValueType) *ResultColumn

func (*ResultColumn) Equal

func (m *ResultColumn) Equal(s *ResultColumn) bool

func (*ResultColumn) SourceName

func (m *ResultColumn) SourceName() string

The source column name

type ResultColumnPb

type ResultColumnPb struct {
	Final            *bool     `protobuf:"varint,1,opt,name=final" json:"final,omitempty"`
	Name             string    `protobuf:"bytes,2,req,name=name" json:"name"`
	ColPos           int32     `protobuf:"varint,3,req,name=colPos" json:"colPos"`
	Column           *ColumnPb `protobuf:"bytes,4,opt,name=column" json:"column,omitempty"`
	Star             *bool     `protobuf:"varint,5,opt,name=star" json:"star,omitempty"`
	As               string    `protobuf:"bytes,6,req,name=as" json:"as"`
	ValueType        int32     `protobuf:"varint,7,req,name=valueType" json:"valueType"`
	XXX_unrecognized []byte    `json:"-"`
}

func (*ResultColumnPb) Descriptor

func (*ResultColumnPb) Descriptor() ([]byte, []int)

func (*ResultColumnPb) GetAs

func (m *ResultColumnPb) GetAs() string

func (*ResultColumnPb) GetColPos

func (m *ResultColumnPb) GetColPos() int32

func (*ResultColumnPb) GetColumn

func (m *ResultColumnPb) GetColumn() *ColumnPb

func (*ResultColumnPb) GetFinal

func (m *ResultColumnPb) GetFinal() bool

func (*ResultColumnPb) GetName

func (m *ResultColumnPb) GetName() string

func (*ResultColumnPb) GetStar

func (m *ResultColumnPb) GetStar() bool

func (*ResultColumnPb) GetValueType

func (m *ResultColumnPb) GetValueType() int32

func (*ResultColumnPb) Marshal

func (m *ResultColumnPb) Marshal() (data []byte, err error)

func (*ResultColumnPb) MarshalTo

func (m *ResultColumnPb) MarshalTo(data []byte) (int, error)

func (*ResultColumnPb) ProtoMessage

func (*ResultColumnPb) ProtoMessage()

func (*ResultColumnPb) Reset

func (m *ResultColumnPb) Reset()

func (*ResultColumnPb) Size

func (m *ResultColumnPb) Size() (n int)

func (*ResultColumnPb) String

func (m *ResultColumnPb) String() string

func (*ResultColumnPb) Unmarshal

func (m *ResultColumnPb) Unmarshal(data []byte) error

type ResultColumns

type ResultColumns []*ResultColumn

ResultColumns List of ResultColumns used to describe projection response columns

type SqlAlter

type SqlAlter struct {
	Raw      string       // full original raw statement
	Identity string       // identity to alter
	Tok      lex.Token    // ALTER [TABLE,VIEW,CONTINUOUSVIEW,TRIGGER] etc
	Cols     []*DdlColumn // columns
}

SqlAlter SQL ALTER statement

func (*SqlAlter) FingerPrint

func (m *SqlAlter) FingerPrint(r rune) string

func (*SqlAlter) Keyword

func (m *SqlAlter) Keyword() lex.TokenType

func (*SqlAlter) String

func (m *SqlAlter) String() string

func (*SqlAlter) WriteDialect

func (m *SqlAlter) WriteDialect(w expr.DialectWriter)

type SqlCommand

type SqlCommand struct {
	Columns  CommandColumns // can have multiple columns in command
	Identity string         //
	Value    expr.Node      //
	// contains filtered or unexported fields
}

SqlCommand is admin command such as "SET", "USE"

func (*SqlCommand) FingerPrint

func (m *SqlCommand) FingerPrint(r rune) string

func (*SqlCommand) Keyword

func (m *SqlCommand) Keyword() lex.TokenType

func (*SqlCommand) String

func (m *SqlCommand) String() string

func (*SqlCommand) WriteDialect

func (m *SqlCommand) WriteDialect(w expr.DialectWriter)

type SqlCreate

type SqlCreate struct {
	Raw         string       // full original raw statement
	Identity    string       // identity of table, view, etc
	Tok         lex.Token    // CREATE [TABLE,VIEW,CONTINUOUSVIEW,TRIGGER] etc
	OrReplace   bool         // OR REPLACE
	IfNotExists bool         // IF NOT EXISTS
	Cols        []*DdlColumn // columns
	Engine      map[string]interface{}
	With        u.JsonHelper
	Select      *SqlSelect
}

SqlCreate SQL CREATE statement

func NewSqlCreate

func NewSqlCreate() *SqlCreate

func (*SqlCreate) FingerPrint

func (m *SqlCreate) FingerPrint(r rune) string

func (*SqlCreate) Keyword

func (m *SqlCreate) Keyword() lex.TokenType

func (*SqlCreate) String

func (m *SqlCreate) String() string

func (*SqlCreate) WriteDialect

func (m *SqlCreate) WriteDialect(w expr.DialectWriter)

type SqlDelete

type SqlDelete struct {
	Table string
	Where *SqlWhere
	Limit int
}

SqlDelete SQL Delete Statement

func NewSqlDelete

func NewSqlDelete() *SqlDelete

func (*SqlDelete) Keyword

func (m *SqlDelete) Keyword() lex.TokenType

func (*SqlDelete) SqlSelect

func (m *SqlDelete) SqlSelect() *SqlSelect

func (*SqlDelete) String

func (m *SqlDelete) String() string

func (*SqlDelete) WriteDialect

func (m *SqlDelete) WriteDialect(w expr.DialectWriter)

type SqlDescribe

type SqlDescribe struct {
	Raw      string    // full original raw statement
	Identity string    // Describe
	Tok      lex.Token // Explain, Describe, Desc
	Stmt     SqlStatement
}

SQL Describe statement

func (*SqlDescribe) Keyword

func (m *SqlDescribe) Keyword() lex.TokenType

func (*SqlDescribe) String

func (m *SqlDescribe) String() string

func (*SqlDescribe) WriteDialect

func (m *SqlDescribe) WriteDialect(w expr.DialectWriter)

type SqlDrop

type SqlDrop struct {
	Raw      string    // full original raw statement
	Identity string    // identity of table, view, etc
	Temp     bool      // Temp?
	Tok      lex.Token // DROP [TEMP] [TABLE,VIEW,CONTINUOUSVIEW,TRIGGER] etc
	With     u.JsonHelper
}

SqlDrop SQL DROP statement

func NewSqlDrop

func NewSqlDrop() *SqlDrop

func (*SqlDrop) FingerPrint

func (m *SqlDrop) FingerPrint(r rune) string

func (*SqlDrop) Keyword

func (m *SqlDrop) Keyword() lex.TokenType

func (*SqlDrop) String

func (m *SqlDrop) String() string

func (*SqlDrop) WriteDialect

func (m *SqlDrop) WriteDialect(w expr.DialectWriter)

type SqlInsert

type SqlInsert struct {
	Table   string           // table name
	Columns Columns          // Column Names
	Rows    [][]*ValueColumn // Values to insert
	Select  *SqlSelect       //
	// contains filtered or unexported fields
}

SqlInsert SQL Insert Statement

func NewSqlInsert

func NewSqlInsert() *SqlInsert

func (*SqlInsert) ColumnNames

func (m *SqlInsert) ColumnNames() []string

func (*SqlInsert) Keyword

func (m *SqlInsert) Keyword() lex.TokenType

func (*SqlInsert) RewriteAsPrepareable

func (m *SqlInsert) RewriteAsPrepareable(maxRows int, mark byte) string

RewriteAsPrepareable rewite the insert as a ? substituteable query

INSERT INTO user (name) VALUES ("wonder-woman") ->
   INSERT INTO user (name) VALUES (?)

func (*SqlInsert) String

func (m *SqlInsert) String() string

func (*SqlInsert) WriteDialect

func (m *SqlInsert) WriteDialect(w expr.DialectWriter)

type SqlInto

type SqlInto struct {
	Table string
}

SqlInto INTO statement (select a,b,c from y INTO z)

func NewSqlInto

func NewSqlInto(table string) *SqlInto

func (*SqlInto) Equal

func (m *SqlInto) Equal(s *SqlInto) bool

func (*SqlInto) Keyword

func (m *SqlInto) Keyword() lex.TokenType

func (*SqlInto) String

func (m *SqlInto) String() string

func (*SqlInto) WriteDialect

func (m *SqlInto) WriteDialect(w expr.DialectWriter)

type SqlSelect

type SqlSelect struct {
	Db       string       // If provided a use "dbname"
	Raw      string       // full original raw statement
	Star     bool         // for select * from ...
	Distinct bool         // Distinct flag?
	Columns  Columns      // An array (ordered) list of columns
	From     []*SqlSource // From, Join
	Into     *SqlInto     // Into "table"
	Where    *SqlWhere    // Expr Node, or *SqlSelect
	Having   expr.Node    // Filter results
	GroupBy  Columns
	OrderBy  Columns
	Limit    int
	Offset   int
	Alias    string       // Non-Standard sql, alias/name of sql another way of expression Prepared Statement
	With     u.JsonHelper // Non-Standard SQL for properties/config info, similar to Cassandra with, purse json
	// contains filtered or unexported fields
}

SqlSelect SQL Select statement

func NewSqlSelect

func NewSqlSelect() *SqlSelect

func ParseSqlSelect

func ParseSqlSelect(sqlQuery string) (*SqlSelect, error)

ParseSqlSelect parse a sql statement as SELECT (or else error)

func ParseSqlSelectResolver

func ParseSqlSelectResolver(sqlQuery string, fr expr.FuncResolver) (*SqlSelect, error)

ParseSqlSelectResolver parse as SELECT using function resolver.

func RewriteSqlSource

func RewriteSqlSource(m *SqlSource, parentStmt *SqlSelect) *SqlSelect

RewriteSqlSource this Source to act as a stand-alone query to backend @parentStmt = the parent statement that this a partial source to

func SqlSelectFromPb

func SqlSelectFromPb(pb *SqlSelectPb) *SqlSelect

SqlSelectFromPb take a protobuf select struct and conver to SqlSelect

func (*SqlSelect) AddColumn

func (m *SqlSelect) AddColumn(colArg Column) error

func (*SqlSelect) AliasedColumns

func (m *SqlSelect) AliasedColumns() map[string]*Column

func (*SqlSelect) ColIndexes

func (m *SqlSelect) ColIndexes() map[string]int

func (*SqlSelect) Copy

func (m *SqlSelect) Copy() *SqlSelect

func (*SqlSelect) CountStar

func (m *SqlSelect) CountStar() bool

Is this a select count(*) FROM ... query?

func (*SqlSelect) Equal

func (m *SqlSelect) Equal(ss SqlStatement) bool

func (*SqlSelect) Finalize

func (m *SqlSelect) Finalize() error

Finalize this Query plan by preparing sub-sources

ie we need to rewrite some things into sub-statements
- we need to share the join expression across sources

func (*SqlSelect) FingerPrintID

func (m *SqlSelect) FingerPrintID() int64

func (*SqlSelect) FromPB

func (m *SqlSelect) FromPB(spb *SqlSelectPb) *SqlSelect

func (*SqlSelect) IsAggQuery

func (m *SqlSelect) IsAggQuery() bool

func (*SqlSelect) IsLiteral

func (m *SqlSelect) IsLiteral() bool

func (*SqlSelect) Keyword

func (m *SqlSelect) Keyword() lex.TokenType

func (*SqlSelect) Rewrite

func (m *SqlSelect) Rewrite()

Rewrite take current SqlSelect statement and re-write it

func (*SqlSelect) RewriteAsRawSelect

func (m *SqlSelect) RewriteAsRawSelect()

RewriteAsRawSelect We are removing Column Aliases "user_id as uid" as well as functions - used when we are going to defer projection, aggs

func (*SqlSelect) SetSystemQry

func (m *SqlSelect) SetSystemQry()

func (*SqlSelect) String

func (m *SqlSelect) String() string

func (*SqlSelect) SystemQry

func (m *SqlSelect) SystemQry() bool

func (*SqlSelect) ToPB

func (m *SqlSelect) ToPB() *SqlSelectPb

func (*SqlSelect) ToPbStatement

func (m *SqlSelect) ToPbStatement() *SqlStatementPb

func (*SqlSelect) UnAliasedColumns

func (m *SqlSelect) UnAliasedColumns() map[string]*Column

func (*SqlSelect) WriteDialect

func (m *SqlSelect) WriteDialect(w expr.DialectWriter)

type SqlSelectPb

type SqlSelectPb struct {
	Db               string         `protobuf:"bytes,1,req,name=db" json:"db"`
	Raw              string         `protobuf:"bytes,2,req,name=raw" json:"raw"`
	Star             bool           `protobuf:"varint,3,req,name=star" json:"star"`
	Distinct         bool           `protobuf:"varint,4,req,name=distinct" json:"distinct"`
	Columns          []*ColumnPb    `protobuf:"bytes,5,rep,name=columns" json:"columns,omitempty"`
	From             []*SqlSourcePb `protobuf:"bytes,6,rep,name=from" json:"from,omitempty"`
	Into             *string        `protobuf:"bytes,7,opt,name=into" json:"into,omitempty"`
	Where            *SqlWherePb    `protobuf:"bytes,8,opt,name=where" json:"where,omitempty"`
	Having           *expr.NodePb   `protobuf:"bytes,9,opt,name=having" json:"having,omitempty"`
	GroupBy          []*ColumnPb    `protobuf:"bytes,11,rep,name=groupBy" json:"groupBy,omitempty"`
	OrderBy          []*ColumnPb    `protobuf:"bytes,10,rep,name=orderBy" json:"orderBy,omitempty"`
	Limit            int32          `protobuf:"varint,12,opt,name=limit" json:"limit"`
	Offset           int32          `protobuf:"varint,13,opt,name=offset" json:"offset"`
	Alias            *string        `protobuf:"bytes,14,opt,name=alias" json:"alias,omitempty"`
	Projection       *ProjectionPb  `protobuf:"bytes,15,opt,name=projection" json:"projection,omitempty"`
	IsAgg            bool           `protobuf:"varint,16,req,name=isAgg" json:"isAgg"`
	Finalized        bool           `protobuf:"varint,17,req,name=finalized" json:"finalized"`
	Schemaqry        bool           `protobuf:"varint,18,req,name=schemaqry" json:"schemaqry"`
	With             []byte         `protobuf:"bytes,19,opt,name=with" json:"with,omitempty"`
	XXX_unrecognized []byte         `json:"-"`
}

func SqlSelectToPb

func SqlSelectToPb(m *SqlSelect) *SqlSelectPb

SqlSelectToPb Given a select statement lets convert it into a PB statement

func (*SqlSelectPb) Descriptor

func (*SqlSelectPb) Descriptor() ([]byte, []int)

func (*SqlSelectPb) GetAlias

func (m *SqlSelectPb) GetAlias() string

func (*SqlSelectPb) GetColumns

func (m *SqlSelectPb) GetColumns() []*ColumnPb

func (*SqlSelectPb) GetDb

func (m *SqlSelectPb) GetDb() string

func (*SqlSelectPb) GetDistinct

func (m *SqlSelectPb) GetDistinct() bool

func (*SqlSelectPb) GetFinalized

func (m *SqlSelectPb) GetFinalized() bool

func (*SqlSelectPb) GetFrom

func (m *SqlSelectPb) GetFrom() []*SqlSourcePb

func (*SqlSelectPb) GetGroupBy

func (m *SqlSelectPb) GetGroupBy() []*ColumnPb

func (*SqlSelectPb) GetHaving

func (m *SqlSelectPb) GetHaving() *expr.NodePb

func (*SqlSelectPb) GetInto

func (m *SqlSelectPb) GetInto() string

func (*SqlSelectPb) GetIsAgg

func (m *SqlSelectPb) GetIsAgg() bool

func (*SqlSelectPb) GetLimit

func (m *SqlSelectPb) GetLimit() int32

func (*SqlSelectPb) GetOffset

func (m *SqlSelectPb) GetOffset() int32

func (*SqlSelectPb) GetOrderBy

func (m *SqlSelectPb) GetOrderBy() []*ColumnPb

func (*SqlSelectPb) GetProjection

func (m *SqlSelectPb) GetProjection() *ProjectionPb

func (*SqlSelectPb) GetRaw

func (m *SqlSelectPb) GetRaw() string

func (*SqlSelectPb) GetSchemaqry

func (m *SqlSelectPb) GetSchemaqry() bool

func (*SqlSelectPb) GetStar

func (m *SqlSelectPb) GetStar() bool

func (*SqlSelectPb) GetWhere

func (m *SqlSelectPb) GetWhere() *SqlWherePb

func (*SqlSelectPb) GetWith

func (m *SqlSelectPb) GetWith() []byte

func (*SqlSelectPb) Marshal

func (m *SqlSelectPb) Marshal() (data []byte, err error)

func (*SqlSelectPb) MarshalTo

func (m *SqlSelectPb) MarshalTo(data []byte) (int, error)

func (*SqlSelectPb) ProtoMessage

func (*SqlSelectPb) ProtoMessage()

func (*SqlSelectPb) Reset

func (m *SqlSelectPb) Reset()

func (*SqlSelectPb) Size

func (m *SqlSelectPb) Size() (n int)

func (*SqlSelectPb) String

func (m *SqlSelectPb) String() string

func (*SqlSelectPb) Unmarshal

func (m *SqlSelectPb) Unmarshal(data []byte) error

type SqlShow

type SqlShow struct {
	Raw        string // full raw statement
	Db         string // Database/Schema name
	Full       bool   // SHOW FULL TABLE FROM
	Scope      string // {FULL, GLOBAL, SESSION}
	ShowType   string // object type, [tables, columns, etc]
	From       string // `table`   or `schema`.`table`
	Identity   string // `table`   or `schema`.`table`
	Create     bool
	CreateWhat string
	Where      expr.Node
	Like       expr.Node
}

SqlShow SQL SHOW Statement

func (*SqlShow) Keyword

func (m *SqlShow) Keyword() lex.TokenType

func (*SqlShow) String

func (m *SqlShow) String() string

func (*SqlShow) WriteDialect

func (m *SqlShow) WriteDialect(w expr.DialectWriter)

type SqlSource

type SqlSource struct {
	Source      *SqlSelect    // Sql Select Source query, written by Rewrite
	Raw         string        // Raw Partial Query
	Name        string        // From Name (optional, empty if join, subselect)
	Alias       string        // From name aliased
	Schema      string        //  FROM `schema`.`table`
	Op          lex.TokenType // In, =, ON
	LeftOrRight lex.TokenType // Left, Right
	JoinType    lex.TokenType // INNER, OUTER
	JoinExpr    expr.Node     // Join expression       x.y = q.y
	SubQuery    *SqlSelect    // optional, Join/SubSelect statement

	// Plan Hints, move to a dedicated planner
	Seekable bool
	// contains filtered or unexported fields
}

SqlSource is a table name, sub-query, or join as used in SELECT <columns> FROM <SQLSOURCE>

  • SELECT .. FROM table_name
  • SELECT .. from (select a,b,c from tableb)
  • SELECT .. FROM tablex INNER JOIN ...

func NewSqlSource

func NewSqlSource(table string) *SqlSource

func SqlSourceFromPb

func SqlSourceFromPb(pb *SqlSourcePb) *SqlSource

func (*SqlSource) BuildColIndex

func (m *SqlSource) BuildColIndex(colNames []string) error

func (*SqlSource) ColumnPositions

func (m *SqlSource) ColumnPositions() map[string]int

Get a list of Column names to position

func (*SqlSource) Equal

func (m *SqlSource) Equal(s *SqlSource) bool

func (*SqlSource) Finalize

func (m *SqlSource) Finalize() error

func (*SqlSource) FromPB

func (m *SqlSource) FromPB(n *SqlSourcePb) *SqlSource

func (*SqlSource) IsLiteral

func (m *SqlSource) IsLiteral() bool

func (*SqlSource) JoinNodes

func (m *SqlSource) JoinNodes() []expr.Node

We need to be able to rewrite statements to convert a stmt such as:

FROM users AS u
    INNER JOIN orders AS o
    ON u.user_id = o.user_id

So that we can evaluate the Join Key on left/right in this case, it is simple, just

=>   user_id

or this one:

		FROM users AS u
			INNER JOIN orders AS o
			ON LOWER(u.email) = LOWER(o.email)

   =>  LOWER(user_id)

func (*SqlSource) Keyword

func (m *SqlSource) Keyword() lex.TokenType

func (*SqlSource) Rewrite

func (m *SqlSource) Rewrite(parentStmt *SqlSelect) *SqlSelect

Rewrite this Source to act as a stand-alone query to backend @parentStmt = the parent statement that this a partial source to

func (*SqlSource) SourceName

func (m *SqlSource) SourceName() string

func (*SqlSource) String

func (m *SqlSource) String() string

func (*SqlSource) ToPB

func (m *SqlSource) ToPB() *SqlSourcePb

func (*SqlSource) UnAliasedColumns

func (m *SqlSource) UnAliasedColumns() map[string]*Column

Get a list of Un-Aliased Columns, ie columns with column

names that have NOT yet been aliased

func (*SqlSource) WriteDialect

func (m *SqlSource) WriteDialect(w expr.DialectWriter)

type SqlSourcePb

type SqlSourcePb struct {
	Final            bool           `protobuf:"varint,1,opt,name=final" json:"final"`
	AliasInner       *string        `protobuf:"bytes,2,opt,name=aliasInner" json:"aliasInner,omitempty"`
	Columns          []*ColumnPb    `protobuf:"bytes,3,rep,name=columns" json:"columns,omitempty"`
	ColIndex         []KvInt        `protobuf:"bytes,4,rep,name=colIndex" json:"colIndex"`
	JoinNodes        []*expr.NodePb `protobuf:"bytes,5,rep,name=joinNodes" json:"joinNodes,omitempty"`
	Source           *SqlSelectPb   `protobuf:"bytes,6,opt,name=source" json:"source,omitempty"`
	Raw              string         `protobuf:"bytes,7,opt,name=raw" json:"raw"`
	Name             string         `protobuf:"bytes,8,opt,name=name" json:"name"`
	Alias            string         `protobuf:"bytes,9,opt,name=alias" json:"alias"`
	Op               int32          `protobuf:"varint,10,req,name=op" json:"op"`
	LeftOrRight      int32          `protobuf:"varint,11,req,name=leftOrRight" json:"leftOrRight"`
	JoinType         int32          `protobuf:"varint,12,req,name=joinType" json:"joinType"`
	JoinExpr         *expr.NodePb   `protobuf:"bytes,13,opt,name=joinExpr" json:"joinExpr,omitempty"`
	SubQuery         *SqlSelectPb   `protobuf:"bytes,14,opt,name=subQuery" json:"subQuery,omitempty"`
	Seekable         bool           `protobuf:"varint,15,opt,name=seekable" json:"seekable"`
	XXX_unrecognized []byte         `json:"-"`
}

func (*SqlSourcePb) Descriptor

func (*SqlSourcePb) Descriptor() ([]byte, []int)

func (*SqlSourcePb) GetAlias

func (m *SqlSourcePb) GetAlias() string

func (*SqlSourcePb) GetAliasInner

func (m *SqlSourcePb) GetAliasInner() string

func (*SqlSourcePb) GetColIndex

func (m *SqlSourcePb) GetColIndex() []KvInt

func (*SqlSourcePb) GetColumns

func (m *SqlSourcePb) GetColumns() []*ColumnPb

func (*SqlSourcePb) GetFinal

func (m *SqlSourcePb) GetFinal() bool

func (*SqlSourcePb) GetJoinExpr

func (m *SqlSourcePb) GetJoinExpr() *expr.NodePb

func (*SqlSourcePb) GetJoinNodes

func (m *SqlSourcePb) GetJoinNodes() []*expr.NodePb

func (*SqlSourcePb) GetJoinType

func (m *SqlSourcePb) GetJoinType() int32

func (*SqlSourcePb) GetLeftOrRight

func (m *SqlSourcePb) GetLeftOrRight() int32

func (*SqlSourcePb) GetName

func (m *SqlSourcePb) GetName() string

func (*SqlSourcePb) GetOp

func (m *SqlSourcePb) GetOp() int32

func (*SqlSourcePb) GetRaw

func (m *SqlSourcePb) GetRaw() string

func (*SqlSourcePb) GetSeekable

func (m *SqlSourcePb) GetSeekable() bool

func (*SqlSourcePb) GetSource

func (m *SqlSourcePb) GetSource() *SqlSelectPb

func (*SqlSourcePb) GetSubQuery

func (m *SqlSourcePb) GetSubQuery() *SqlSelectPb

func (*SqlSourcePb) Marshal

func (m *SqlSourcePb) Marshal() (data []byte, err error)

func (*SqlSourcePb) MarshalTo

func (m *SqlSourcePb) MarshalTo(data []byte) (int, error)

func (*SqlSourcePb) ProtoMessage

func (*SqlSourcePb) ProtoMessage()

func (*SqlSourcePb) Reset

func (m *SqlSourcePb) Reset()

func (*SqlSourcePb) Size

func (m *SqlSourcePb) Size() (n int)

func (*SqlSourcePb) String

func (m *SqlSourcePb) String() string

func (*SqlSourcePb) Unmarshal

func (m *SqlSourcePb) Unmarshal(data []byte) error

type SqlSourceStatement

type SqlSourceStatement interface {
	// string representation of Node, AST parseable back to itself
	String() string
	// Write out this statement in a specific dialect
	WriteDialect(w expr.DialectWriter)
	// SQL Keyword for this statement
	Keyword() lex.TokenType
}

SqlSourceStatement interface, to define the subselect/join-types Join, SubSelect, From

type SqlStatement

type SqlStatement interface {
	// string representation of Node, AST parseable back to itself
	String() string
	// Write out this statement in a specific dialect
	WriteDialect(w expr.DialectWriter)
	// SQL keyword (select, insert, etc)
	Keyword() lex.TokenType
}

SqlStatement interface, to define the sql statement Select, Insert, Update, Delete, Command, Show, Describe etc

func ParseSql

func ParseSql(sqlQuery string) (SqlStatement, error)

ParseSql Parses SqlStatement and returns a statement or error does not parse more than one statement

func ParseSqlStatements

func ParseSqlStatements(sqlQuery string) ([]SqlStatement, error)

ParseSqlStatements into array of SQL Statements

func SqlFromPb

func SqlFromPb(pb []byte) (SqlStatement, error)

SqlFromPb Create a sql statement from pb

type SqlStatementPb

type SqlStatementPb struct {
	Select           *SqlSelectPb  `protobuf:"bytes,1,opt,name=select" json:"select,omitempty"`
	Source           *SqlSourcePb  `protobuf:"bytes,2,opt,name=source" json:"source,omitempty"`
	Projection       *ProjectionPb `protobuf:"bytes,4,opt,name=projection" json:"projection,omitempty"`
	XXX_unrecognized []byte        `json:"-"`
}

The generic SqlStatement, must be exactly one of these types

func (*SqlStatementPb) Descriptor

func (*SqlStatementPb) Descriptor() ([]byte, []int)

func (*SqlStatementPb) GetProjection

func (m *SqlStatementPb) GetProjection() *ProjectionPb

func (*SqlStatementPb) GetSelect

func (m *SqlStatementPb) GetSelect() *SqlSelectPb

func (*SqlStatementPb) GetSource

func (m *SqlStatementPb) GetSource() *SqlSourcePb

func (*SqlStatementPb) Marshal

func (m *SqlStatementPb) Marshal() (data []byte, err error)

func (*SqlStatementPb) MarshalTo

func (m *SqlStatementPb) MarshalTo(data []byte) (int, error)

func (*SqlStatementPb) ProtoMessage

func (*SqlStatementPb) ProtoMessage()

func (*SqlStatementPb) Reset

func (m *SqlStatementPb) Reset()

func (*SqlStatementPb) Size

func (m *SqlStatementPb) Size() (n int)

func (*SqlStatementPb) String

func (m *SqlStatementPb) String() string

func (*SqlStatementPb) Unmarshal

func (m *SqlStatementPb) Unmarshal(data []byte) error

type SqlTokenPager

type SqlTokenPager struct {
	*expr.LexTokenPager
	// contains filtered or unexported fields
}

TokenPager is responsible for determining end of current tree (column, etc)

func NewSqlTokenPager

func NewSqlTokenPager(l *lex.Lexer) *SqlTokenPager

func (*SqlTokenPager) ClauseEnd

func (m *SqlTokenPager) ClauseEnd() bool

func (*SqlTokenPager) IsEnd

func (m *SqlTokenPager) IsEnd() bool

type SqlUpdate

type SqlUpdate struct {
	Values map[string]*ValueColumn
	Where  *SqlWhere
	Table  string
}

SqlUpdate SQL Update Statement

func NewSqlUpdate

func NewSqlUpdate() *SqlUpdate

func (*SqlUpdate) Keyword

func (m *SqlUpdate) Keyword() lex.TokenType

func (*SqlUpdate) SqlSelect

func (m *SqlUpdate) SqlSelect() *SqlSelect

func (*SqlUpdate) String

func (m *SqlUpdate) String() string

func (*SqlUpdate) WriteDialect

func (m *SqlUpdate) WriteDialect(w expr.DialectWriter)

type SqlUpsert

type SqlUpsert struct {
	Columns Columns
	Rows    [][]*ValueColumn
	Values  map[string]*ValueColumn
	Where   *SqlWhere
	Table   string
}

SqlUpsert SQL Upsert Statement

func NewSqlUpsert

func NewSqlUpsert() *SqlUpsert

func (*SqlUpsert) Keyword

func (m *SqlUpsert) Keyword() lex.TokenType

func (*SqlUpsert) SqlSelect

func (m *SqlUpsert) SqlSelect() *SqlSelect

func (*SqlUpsert) String

func (m *SqlUpsert) String() string

func (*SqlUpsert) WriteDialect

func (m *SqlUpsert) WriteDialect(w expr.DialectWriter)

type SqlWhere

type SqlWhere struct {
	// Either Op + Source exists
	Op     lex.TokenType // (In|=|ON)  for Select Clauses operators
	Source *SqlSelect    // IN (SELECT a,b,c from z)

	// OR expr but not both
	Expr expr.Node // x = y AND q > 5
}

SqlWhere WHERE is select stmt, or set of expressions - WHERE x in (select name from q) - WHERE x = y - WHERE x = y AND z = q - WHERE tolower(x) IN (select name from q)

func NewSqlWhere

func NewSqlWhere(where expr.Node) *SqlWhere

func SqlWhereFromPb

func SqlWhereFromPb(pb *SqlWherePb) *SqlWhere

func (*SqlWhere) Equal

func (m *SqlWhere) Equal(s *SqlWhere) bool

func (*SqlWhere) Keyword

func (m *SqlWhere) Keyword() lex.TokenType

func (*SqlWhere) String

func (m *SqlWhere) String() string

func (*SqlWhere) WriteDialect

func (m *SqlWhere) WriteDialect(w expr.DialectWriter)

type SqlWherePb

type SqlWherePb struct {
	Op               int32        `protobuf:"varint,1,req,name=op" json:"op"`
	Source           *SqlSelectPb `protobuf:"bytes,2,opt,name=source" json:"source,omitempty"`
	Expr             *expr.NodePb `protobuf:"bytes,3,opt,name=Expr,json=expr" json:"Expr,omitempty"`
	XXX_unrecognized []byte       `json:"-"`
}

func SqlWhereToPb

func SqlWhereToPb(m *SqlWhere) *SqlWherePb

func (*SqlWherePb) Descriptor

func (*SqlWherePb) Descriptor() ([]byte, []int)

func (*SqlWherePb) GetExpr

func (m *SqlWherePb) GetExpr() *expr.NodePb

func (*SqlWherePb) GetOp

func (m *SqlWherePb) GetOp() int32

func (*SqlWherePb) GetSource

func (m *SqlWherePb) GetSource() *SqlSelectPb

func (*SqlWherePb) Marshal

func (m *SqlWherePb) Marshal() (data []byte, err error)

func (*SqlWherePb) MarshalTo

func (m *SqlWherePb) MarshalTo(data []byte) (int, error)

func (*SqlWherePb) ProtoMessage

func (*SqlWherePb) ProtoMessage()

func (*SqlWherePb) Reset

func (m *SqlWherePb) Reset()

func (*SqlWherePb) Size

func (m *SqlWherePb) Size() (n int)

func (*SqlWherePb) String

func (m *SqlWherePb) String() string

func (*SqlWherePb) Unmarshal

func (m *SqlWherePb) Unmarshal(data []byte) error

type Sqlbridge

type Sqlbridge struct {
	*SqlTokenPager
	// contains filtered or unexported fields
}

Sqlbridge generic SQL parser evaluates should be sufficient for most sql compatible languages

type ValueColumn

type ValueColumn struct {
	Value value.Value
	Expr  expr.Node
}

ValueColumn List of Value columns in INSERT into TABLE (colnames) VALUES (valuecolumns)

Jump to

Keyboard shortcuts

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