Skip to content

Confusing errors when postgres column description is not a valid rust ident #702

Open
@jyn514

Description

@jyn514
error: found invalid character; only `#` is allowed in raw string delimitation: \u{0}
   --> src/docbuilder/rustwide_builder.rs:643:16
    |
643 |               Ok(query!(
    |  ________________^
644 | |                     "SELECT 1 FROM crates, releases, builds
645 | |                      WHERE crates.id = releases.crate_id AND releases.id = builds.rid
646 | |                        AND crates.name = $1 AND releases.version = $2
647 | |                        AND builds.build_status = TRUE;",
648 | |                     name, version,
649 | |                 )
    | |_________________^

and with the same span

error: column name "?column?" is invalid: "" is not a valid Rust identifier

The fix was to change SELECT 1 to SELECT 1 as x.

Macro Backtrace
error: found invalid character; only `#` is allowed in raw string delimitation: \u{0}
   --> /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-0.4.0-beta.1/src/macros.rs:292:9
    |
278 | / macro_rules! query (
279 | |     // in Rust 1.45 we can now invoke proc macros in expression position
280 | |     ($query:expr) => ({
281 | |         $crate::sqlx_macros::expand_query!(source = $query)
...   |
292 | |         $crate::sqlx_macros::expand_query!(source = $query, args = [$($args)*])
    | |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation
293 | |     })
294 | | );
    | |__- in this expansion of `query!`
    | 
   ::: /home/joshua/.local/lib/cargo/registry/src/github.com-1ecc6299db9ec823/sqlx-macros-0.4.0-beta.1/src/lib.rs:24:1
    |
24  | / pub fn expand_query(input: TokenStream) -> TokenStream {
25  | |     let input = syn::parse_macro_input!(input as query::QueryMacroInput);
26  | |
27  | |     match query::expand_input(input) {
...   |
37  | |     }
38  | | }
    | |_- in this expansion of `$crate::sqlx_macros::expand_query!`
    | 
   ::: src/docbuilder/rustwide_builder.rs:643:16
    |
643 |               Ok(query!(
    |  ________________-
644 | |                     "SELECT 1 FROM crates, releases, builds
645 | |                      WHERE crates.id = releases.crate_id AND releases.id = builds.rid
646 | |                        AND crates.name = $1 AND releases.version = $2
647 | |                        AND builds.build_status = TRUE;",
648 | |                     name, version,
649 | |                 )
    | |_________________- in this macro invocation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions