Skip to content
This repository has been archived by the owner on Jun 3, 2024. It is now read-only.

Commit

Permalink
SafeToSql util fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaiba committed Mar 22, 2024
1 parent 818b79f commit 0dd4977
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions schema/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,22 @@ func (c *ContextValidator) visitActions(actions []Action) error {
}

for _, statement := range a.Statements {
stmt, err := actparser.Parse(statement)
actStmt, err := actparser.Parse(statement)
if err != nil {
return fmt.Errorf("%w: %s", err, statement)
}

switch s := stmt.(type) {
switch s := actStmt.(type) {
case *actparser.DMLStmt:
astTree, err := sqlparser.ParseSql(statement, 1, nil, false)
sqlStmt, err := sqlparser.ParseSql(statement, 1, nil, false, false)
if err != nil {
return fmt.Errorf("%w: %s", err, statement)
}
if _, err := astTree.ToSQL(); err != nil {
if _, err := tree.SafeToSQL(sqlStmt); err != nil {
return fmt.Errorf("%w: %s", err, statement)
}
// TODO: validate reference in SQL statement
//switch t := astTree.(type) {
//switch t := sqlStmt.(type) {
//case *tree.Select:
case *actparser.ActionCallStmt:
if _, ok := c.actionCtx[s.Method]; !ok {
Expand Down

0 comments on commit 0dd4977

Please sign in to comment.