Documentation
¶
Index ¶
- type Extractor
- func (e *Extractor) Extract() (err error)
- func (e *Extractor) HasParamMarker() []bool
- func (e *Extractor) OpType() []models.SQLOpType
- func (e *Extractor) Params() [][]any
- func (e *Extractor) RawSQL() string
- func (e *Extractor) SetRawSQL(sql string)
- func (e *Extractor) TableInfos() [][]*models.TableInfo
- func (e *Extractor) TemplatizedSQL() []string
- func (e *Extractor) TemplatizedSQLHash(fn ...func([]byte) string) []string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor is a struct that holds the raw SQL, templatized SQL, operation type, parameters and table information. It is used to extract information from a SQL string.
func NewExtractor ¶
NewExtractor creates a new Extractor. It requires a raw SQL string.
func (*Extractor) Extract ¶
Extract extracts information from the raw SQL string. It extracts the templatized SQL, parameters, table information, and operation type.
Example:
extractor := NewExtractor("SELECT * FROM users WHERE id = 1") err := extractor.Extract() if err != nil { // handle error } fmt.Println(extractor.TemplatizeSQL())
func (*Extractor) HasParamMarker ¶ added in v1.1.0
HasParamMarker returns whether the SQLs contains parameter markers.
func (*Extractor) TableInfos ¶
TableInfos returns the table infos.
func (*Extractor) TemplatizedSQL ¶
TemplatizedSQL returns the templatized SQL.
Click to show internal directories.
Click to hide internal directories.