package
0.0.0-20201126024400-cc8f96a18079
Repository: https://github.com/toontong/sqlz.git
Documentation: pkg.go.dev
# README
sqlparser
this folder code was from mix which base on vitess
I was changed something.
Usage
import (
"sqlparser"
)
stmt, err = sqlparser.Parse("SELECT * FROM t1")
if err != nil{
println("Parse success.")
}
switch sql := stmt.(type) {
case *sqlparser.Select:
typ = SELECT
case *sqlparser.Insert:
typ = INSERT
case *sqlparser.DDL:
switch sql.Action {
case sqlparser.AST_CREATE:
case sqlparser.AST_RENAME:
default: println("do what you want with DDL SQL.")
}
....// case SQL other type.
....
default:
// do what you want.
}
# Packages
Package sqltypes implements interfaces and types that represent SQL values.
# Functions
AsInterface converts the ValExpr to an interface.
No description provided by the author
No description provided by the author
GetColName returns the column name, only if it's a simple expression.
GetDBName parses the specified DML and returns the db name if it was used to qualify the table name.
GetTableName returns the table name from the SimpleTableExpr only if it's a simple expression.
HasINCaluse returns true if an yof the conditions has an IN clause.
IsColName returns true if the ValExpr is a *ColName.
IsSimpleTuple returns true if the ValExpr is a ValTuple that contains simple values.
IsVal returns true if the ValExpr is a string, number or value arg.
No description provided by the author
NewStringTokenizer creates a new Tokenizer for the sql string.
No description provided by the author
NewWhere creates a WHERE or HAVING clause out of a BoolExpr.
Parse parses the sql and returns a Statement, which is the AST representation of the query.
No description provided by the author
No description provided by the author
String returns a string representation of an SQLNode.
StringIn is a convenience function that returns true if str matches any of the values.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Order.Direction.
RangeCond.Operator.
BinaryExpr.Operator.
BinaryExpr.Operator.
BinaryExpr.Operator.
No description provided by the author
JoinTableExpr.Join.
Order.Direction.
Select.Distinct.
BinaryExpr.Operator.
No description provided by the author
ComparisonExpr.Operator.
Union.Type.
Select.Lock.
No description provided by the author
ComparisonExpr.Operator.
ComparisonExpr.Operator.
Where.Type.
No description provided by the author
ComparisonExpr.Operator.
Union.Type.
NullCheck.Operator.
NullCheck.Operator.
JoinTableExpr.Join.
ComparisonExpr.Operator.
JoinTableExpr.Join.
ComparisonExpr.Operator.
ComparisonExpr.Operator.
BinaryExpr.Operator.
BinaryExpr.Operator.
BinaryExpr.Operator.
JoinTableExpr.Join.
ComparisonExpr.Operator.
RangeCond.Operator.
ComparisonExpr.Operator.
ComparisonExpr.Operator.
ComparisonExpr.Operator.
BinaryExpr.Operator.
No description provided by the author
JoinTableExpr.Join.
Union.Type.
Select.Lock.
JoinTableExpr.Join.
UnaryExpr.Operator.
UnaryExpr.Operator.
Union.Type.
Union.Type.
UnaryExpr.Operator.
No description provided by the author
Where.Type.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
AliasedTableExpr represents a table expression coupled with an optional alias or index hint.
AndExpr represents an AND expression.
No description provided by the author
BinaryExpr represents a binary value expression.
No description provided by the author
CaseExpr represents a CASE expression.
ColName represents a column name.
No description provided by the author
ComparisonExpr represents a two-value comparison expression.
DDL represents a CREATE, ALTER, DROP or RENAME statement.
Delete represents a DELETE statement.
ExistsExpr represents an EXISTS expression.
FuncExpr represents a function call.
IndexHints represents a list of index hints.
Insert represents an INSERT statement.
JoinTableExpr represents a TableExpr that's a JOIN operation.
Limit represents a LIMIT clause.
NonStarExpr defines a non-'*' select expr.
NotExpr represents a NOT expression.
NullCheck represents an IS NULL or an IS NOT NULL expression.
NullVal represents a NULL value.
Order represents an ordering expression.
OrExpr represents an OR expression.
ParenBoolExpr represents a parenthesized boolean expression.
ParenTableExpr represents a parenthesized TableExpr.
No description provided by the author
ParserError: To be deprecated.
RangeCond represents a BETWEEN or a NOT BETWEEN expression.
Replace represents an REPLACE statement.
No description provided by the author
Select represents a SELECT statement.
Set represents a SET statement.
No description provided by the author
No description provided by the author
StarExpr defines a '*' or 'table.*' expression.
Subquery represents a subquery.
TableName represents a table name.
Tokenizer is the struct used to generate SQL tokens for the parser.
TrackedBuffer is used to rebuild a query from the ast.
UnaryExpr represents a unary value expression.
Union represents a UNION statement.
Update represents an UPDATE statement.
UpdateExpr represents an update expression.
When represents a WHEN sub-expression.
Where represents a WHERE or HAVING clause.
# Interfaces
BoolExpr represents a boolean expression.
Expr represents an expression.
InsertRows represents the rows for an INSERT statement.
SelectExpr represents a SELECT expression.
SelectStatement any SELECT statement.
SimpleTableExpr represents a simple table expression.
SQLNode defines the interface for all nodes generated by the parser.
Statement represents a statement.
TableExpr represents a table expression.
Tuple represents a tuple.
ValExpr represents a value expression.
# Type aliases
Columns represents an insert column list.
Comments represents a list of comments.
No description provided by the author
GroupBy represents a GROUP BY clause.
NumVal represents a number.
OnDup represents an ON DUPLICATE KEY clause.
OrderBy represents an ORDER By clause.
SelectExprs represents SELECT expressions.
StrVal represents a string value.
TableExprs represents a list of table expressions.
UpdateExprs represents a list of update expressions.
ValArg represents a named bind var argument.
ValExprs represents a list of value expressions.
ValTuple represents a tuple of actual values.
Values represents a VALUES clause.