Skip to content

parseStatement failed: parseObjectName failed: parseListOfId: expect identifier #51

Description

@sunshine69

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>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions