-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
I got a sample code below, however it can not parse
package main
import (
"bytes"
"log"
"github.com/k0kubun/pp"
"github.com/akito0107/xsqlparser"
"github.com/akito0107/xsqlparser/dialect"
"github.com/akito0107/xsqlparser/sqlast"
)
func main() {
parseCreate()
}
func parseCreate() {
sql := "CREATE TABLE IF NOT EXISTS `somadatabase`.`sometable` ( `clientID` char(36) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL COMMENT 'Client', `monday` int(11) NOT NULL COMMENT ' Mondays', `tuesday` int(11) NOT NULL COMMENT ' Tuesdays', `wednesday` int(11) NOT NULL COMMENT ' Wednesdays', `thursday` int(11) NOT NULL COMMENT ' Thursdays', `friday` int(11) NOT NULL COMMENT ' Fridays', `saturday` int(11) NOT NULL COMMENT ' Saturdays', `sunday` int(11) NOT NULL COMMENT ' Sundays', `allowanceOnUpdate` int(11) DEFAULT NULL COMMENT 'Previous allowance for the day affected by the last update', `updated` timestamp(6) NOT NULL, PRIMARY KEY (`clientID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;"
parser, err := xsqlparser.NewParser(bytes.NewBufferString(sql), &dialect.GenericSQLDialect{})
if err != nil {
log.Fatal(err)
}
stmt, err := parser.ParseStatement()
if err != nil {
log.Fatalf("[ERROR] %s", err)
}
pp.Println(stmt)
}
stevek@work-macbook 14:41 ~/s/g/xsqlparser> go run .
2022/06/10 14:41:39 [ERROR] parseStatement failed: parseObjectName failed: parseListOfId: expect identifier
exit status 1
stevek@work-macbook 14:41 ~/s/g/xsqlparser>
Metadata
Metadata
Assignees
Labels
No labels