auxten / postgresql-parser

Pure Golang PostgreSQL (SQL:2011, SQL:2008, SQL:2003, SQL:1999, and SQL-92 Standard) Parser
Apache License 2.0
273 stars 50 forks source link

Parser Better Error Handling #29

Closed kefniark closed 2 months ago

kefniark commented 2 months ago

Description

Right now when the parser fail with an unknown syntax, the error is really minimal, which to debug on a mid/big size schema is near impossible. Is there a way to get more information out of this error like the line number ?

stmts, err := parser.Parse(sql)
if err != nil {
    return err
}
Error: at or near "(": syntax error
kefniark commented 2 months ago

My bad, I was just dumb on that one. The info is there, the error was just wrap few level deeper

fmt.Printf("schema parsing error: %+v\n", err)