Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line number in the syntax error message in CI #365

Open
jiwoongim opened this issue Jul 10, 2024 · 1 comment
Open

Line number in the syntax error message in CI #365

jiwoongim opened this issue Jul 10, 2024 · 1 comment

Comments

@jiwoongim
Copy link

Is there a way to output the line number when it gives a syntax error?

For example, I get

note: Postgres failed to parse query: syntax error at or near "("
help: Modify your Postgres statement to use valid syntax.

it is hard to find which line the syntax error. comes from.

@sbdchd
Copy link
Owner

sbdchd commented Jul 11, 2024

Yeah definitely possible to add, the libpg_query-sys crate has:

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct PgQueryError {
    pub message: *mut ::std::os::raw::c_char,
    pub funcname: *mut ::std::os::raw::c_char,
    pub filename: *mut ::std::os::raw::c_char,
    pub lineno: ::std::os::raw::c_int,
    pub cursorpos: ::std::os::raw::c_int,
    pub context: *mut ::std::os::raw::c_char,
}

but we only use the message field from it:

let err = *pg_parse_result.error;
return Err(PgQueryError::PgParseError(parse_str_or_none(err.message)));

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

No branches or pull requests

2 participants