Documentation
¶
Index ¶
- func NewSQLParser() sqlparser.SQLParser
- type AliasCollector
- type Impl
- func (p *Impl) AddColumnsToInsertSQL(origSQL string, addCols []sqlparser.ColumnValue, ...) (string, map[string]bool, error)
- func (p *Impl) AddSelectFieldsToSelectSQL(origSQL string, cols []string) (string, error)
- func (p *Impl) AppendSQLFilter(sql string, op sqlparser.SQLFilterOp, filter string) (string, error)
- func (p *Impl) GetInsertDataNums(sql string) (int, error)
- func (p *Impl) GetSQLOperation(sql string) (sqlparser.OperationType, error)
- func (p *Impl) GetTableName(sql string) (string, error)
- func (p *Impl) ParseAndModifySQL(sql string, tableColumns map[string]sqlparser.TableColumn) (string, error)
- type SQLModifier
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AliasCollector ¶
type AliasCollector struct {
// contains filtered or unexported fields
}
AliasCollector collects table aliases in a first pass
func NewAliasCollector ¶
func NewAliasCollector() *AliasCollector
NewAliasCollector creates a new alias collector
type Impl ¶
type Impl struct {
// contains filtered or unexported fields
}
Impl implements the SQLParser interface
func (*Impl) AddColumnsToInsertSQL ¶
func (p *Impl) AddColumnsToInsertSQL(origSQL string, addCols []sqlparser.ColumnValue, primaryKeyValue *sqlparser.PrimaryKeyValue, isParam bool) (string, map[string]bool, error)
AddColumnsToInsertSQL takes an original insert SQL and columns to add (with values), returns the modified SQL. addCols: a slice of ColumnValue, where each element represents a column and its value to be inserted for every row. primaryKeyValue: a PrimaryKeyValue struct that contains the primary key column name and its values for every row, only supported for single primary key. If isParam is true, placeholders (?) will be added as values, otherwise the actual values from addCols will be used.
func (*Impl) AddSelectFieldsToSelectSQL ¶
func (*Impl) AppendSQLFilter ¶
func (*Impl) GetSQLOperation ¶
func (p *Impl) GetSQLOperation(sql string) (sqlparser.OperationType, error)
GetSQLOperation implements the SQLParser interface
func (*Impl) GetTableName ¶
GetTableName extracts the table name from a SQL statement. Only supports single-table select/insert/update/delete.
func (*Impl) ParseAndModifySQL ¶
type SQLModifier ¶
type SQLModifier struct {
// contains filtered or unexported fields
}
SQLModifier is used to modify SQL AST
func NewSQLModifier ¶
func NewSQLModifier(tableColumns map[string]sqlparser.TableColumn, tableAliases map[string]string) *SQLModifier
NewSQLModifier creates a new SQL modifier with pre-collected aliases