parser

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeTableName

func NormalizeTableName(name string) string

NormalizeTableName removes backticks and quotes from table name

Types

type ParsedQuery

type ParsedQuery struct {
	Original        string
	Type            QueryType
	Statement       sqlparser.Statement
	TableName       string
	CurrencyColumns []string
	Values          map[string]interface{}
	NeedsTransform  bool
}

ParsedQuery represents a parsed SQL query with metadata

type Parser

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

Parser handles SQL query parsing and analysis

func NewParser

func NewParser(tableConfig config.TablesConfig) *Parser

NewParser creates a new SQL parser

func (*Parser) Parse

func (p *Parser) Parse(query string) (*ParsedQuery, error)

Parse parses a SQL query and returns metadata

func (*Parser) RewriteForDualWrite

func (p *Parser) RewriteForDualWrite(pq *ParsedQuery, convertedValues map[string]float64) (string, error)

RewriteForDualWrite rewrites a query to include shadow columns

type QueryType

type QueryType int

QueryType represents the type of SQL query

const (
	QueryTypeUnknown QueryType = iota
	QueryTypeSelect
	QueryTypeInsert
	QueryTypeUpdate
	QueryTypeDelete
)

func (QueryType) IsMutation

func (qt QueryType) IsMutation() bool

IsMutation returns true if the query mutates data

func (QueryType) String

func (qt QueryType) String() string

GetQueryType returns a string representation of query type

Jump to

Keyboard shortcuts

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