sqlparser

package
v0.0.0-...-34c40b2 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSQLParser

func NewSQLParser() sqlparser.SQLParser

NewSQLParser creates a new SQL parser

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

func (*AliasCollector) Enter

func (c *AliasCollector) Enter(n ast.Node) (ast.Node, bool)

Enter implements ast.Visitor interface

func (*AliasCollector) Leave

func (c *AliasCollector) Leave(n ast.Node) (ast.Node, bool)

Leave implements ast.Visitor interface

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 (p *Impl) AddSelectFieldsToSelectSQL(origSQL string, cols []string) (string, error)

func (*Impl) AppendSQLFilter

func (p *Impl) AppendSQLFilter(sql string, op sqlparser.SQLFilterOp, filter string) (string, error)

func (*Impl) GetInsertDataNums

func (p *Impl) GetInsertDataNums(sql string) (int, error)

func (*Impl) GetSQLOperation

func (p *Impl) GetSQLOperation(sql string) (sqlparser.OperationType, error)

GetSQLOperation implements the SQLParser interface

func (*Impl) GetTableName

func (p *Impl) GetTableName(sql string) (string, error)

GetTableName extracts the table name from a SQL statement. Only supports single-table select/insert/update/delete.

func (*Impl) ParseAndModifySQL

func (p *Impl) ParseAndModifySQL(sql string, tableColumns map[string]sqlparser.TableColumn) (string, error)

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

func (*SQLModifier) Enter

func (m *SQLModifier) Enter(n ast.Node) (ast.Node, bool)

Enter implements ast.Visitor interface

func (*SQLModifier) Leave

func (m *SQLModifier) Leave(n ast.Node) (ast.Node, bool)

Leave implements ast.Visitor interface

Jump to

Keyboard shortcuts

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