Files
mayfly-go/server/pkg/base/sql_test.go
meilin.huang 99a746085b feat: i18n
2024-11-20 22:43:53 +08:00

29 lines
511 B
Go

package base
import (
"fmt"
"testing"
)
func TestParserSql(t *testing.T) {
sql := `-- selectByCond
Select * from tdb where id > 10;
-- another comment
Select * from another_table where name = 'test'
and age = ?;
-- multi-line comment
-- continues here
Select * from yet_another_table
Where id = ?;`
statements, err := parseSQL(sql)
if err != nil {
fmt.Println("Error:", err)
return
}
for _, stmt := range statements {
fmt.Printf("Comment: %s\nSQL: %s\n\n", stmt.Comment, stmt.SQL)
}
}