sqld icon indicating copy to clipboard operation
sqld copied to clipboard

SQL parse errors difficult to understand

Open CodingDoug opened this issue 2 years ago • 2 comments

A few examples:

select * from table_name,;

SQL string could not be parsed: near SEMI, "None": syntax error at (1, 27)

create table table_name (
    text_ text,
);

SQL string could not be parsed: near RP, "None": syntax error at (3, 2)

In all cases, the "None" doesn't seem to be helpful at all. Maybe that's a rust string format thing.

I'm not really sure what information we have at our disposal to improve this. The sqlite3 CLI:

  • Shows surrounding text
  • Points an arrow at the location of the parse error
  • Converts symbols like "RP" to ")"

CodingDoug avatar Jun 05 '23 21:06 CodingDoug

@CodingDoug, I agree this should be improved. I'm not sure showing text is going to be helpful without proper formatting, but we could return a machine-readable error object:

type ParseError = {
    line: int,
    char: int,
    message: string,
}

MarinPostma avatar Jun 08 '23 13:06 MarinPostma

Yeah, breaking out all that data would make it easier for clients to format their own error messages.

CodingDoug avatar Jun 08 '23 13:06 CodingDoug