sqlparser
sqlparser copied to clipboard
SQL Parser implemented in Go
I want to validate some SQL queries that are nested and have sub-queries at multiple depths. The `sqlparser.Parse` says the following query is invalid:- ```sql SELECT ( SELECT ( SELECT...
https://dev.mysql.com/doc/refman/8.0/en/with.html#common-table-expressions-syntax
s [SyntaxError]: Expected "!=", "#-", "#>", "#>>", "%", "&&", ")", "*", "+", ",", "-", "--", "/", "/*", "::", "", "AND", "BETWEEN", "ILIKE", "IN", "IS", "LIKE", "NOT", "OR", "SIMILAR", "||", or...
### SQL CREATE TABLE t1 ( ts TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6) ); ### Error ignoring error parsing DDL 'CREATE TABLE t1 (ts TIMESTAMP(6) DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6));':...
``` INSERT INTO `products` (`created_at`,`updated_at`,`deleted_at`,`code`,`price`) VALUES ("2022-12-13 03:09:51.724","2022-12-13 03:09:51.724",NULL,"D42",100) RETURNING `id` ``` syntax error at position 165 near 'RETURNING'
```go stmt, err := sqlparser.Parse(`select * from information_schema.processlist`) if err != nil { log.Println("解析错误:", err.Error()) return } log.Println(stmt) ``` result: ```go 2019/03/29 15:31:38 解析错误: syntax error at position 45 near...
func main() { sql := "SELECT * FROM table WHERE a = 'abc'" stmt, err := sqlparser.Parse(sql) if err != nil { fmt.Printf("%s",err.Error()) } // Otherwise do something with stmt...
I have an SQL procedure in MariaDB called `bookUPDATE` such as this: ```sql BEGIN UPDATE book SET book.Title= v_Title, book.ReleaseDate = v_ReleaseDate, book.Description = v_Description, WHERE book.ID = v_ID; END...
full cast function support fix https://github.com/xwb1989/sqlparser/issues/40
Fixed casting to an int, mentioned in https://github.com/xwb1989/sqlparser/issues/40 ```sql select * from S3Object where cast(age AS int) > 12 ``` One can use `go get github.com/carterharrison/sqlparser` for current fix.