convertOmniError converts an omni parser error to a base.SyntaxError with proper line:column position.
(err error, _ string, stmt base.Statement)
| 51 | |
| 52 | // convertOmniError converts an omni parser error to a base.SyntaxError with proper line:column position. |
| 53 | func convertOmniError(err error, _ string, stmt base.Statement) error { |
| 54 | var parseErr *omniparser.ParseError |
| 55 | if !errors.As(err, &parseErr) { |
| 56 | return err |
| 57 | } |
| 58 | |
| 59 | // Convert byte offset within stmt.Text to line:column. |
| 60 | pos := ByteOffsetToRunePosition(stmt.Text, parseErr.Position) |
| 61 | |
| 62 | // Adjust line by the statement's base line (stmt.Start.Line is 1-based). |
| 63 | if stmt.Start != nil { |
| 64 | pos.Line += stmt.Start.Line - 1 |
| 65 | } |
| 66 | |
| 67 | return &base.SyntaxError{ |
| 68 | Position: pos, |
| 69 | Message: fmt.Sprintf("Syntax error at line %d: %s", pos.Line, parseErr.Message), |
| 70 | RawMessage: parseErr.Message, |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // normalizePostgreSQLQuotedIdentifier removes surrounding double quotes and unescapes internal ones. |
| 75 | func normalizePostgreSQLQuotedIdentifier(s string) string { |
no test coverage detected