Skip to content

Column output override type truncates itself after ~64 characters #4036

@KennanHunter

Description

@KennanHunter

I have found these related issues/pull requests

No related issues found.

Description

If the field name + type name is too long, sqlx will truncate the type name. This is an error generated by cargo build

error[E0412]: cannot find type `ThisIsAExcessiv` in this scope
   --> 
    |
  1 | ...   sqlx::query!(r#"SELECT count(*) as "excessively_long_field_name_used_for_reference: ThisIsAExcessivelyLongNameToGetErrorWithTypeNaming" FROM users"#) 
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
not found in this scope
    |
    = note: this error originates in the macro `$crate::sqlx_macros::expand_query` which comes from the expansion of the macro `sqlx::query` (in Nightly builds, run with -Z macro-backtrace for more info)

Reproduction steps

#[tokio::test]
async fn big_type_name() {
    let pool = sqlx::PgPool::connect()
        .await
        .expect("Can connect to postgres");

    #[derive(sqlx::Type, Debug)]
    #[sqlx(transparent)]
    struct ThisIsAExcessivelyLongNameToGetErrorWithTypeNaming(i64);

    sqlx::query!(r#"SELECT count(*) as "excessively_long_field_name_used_for_reference: ThisIsAExcessivelyLongNameToGetErrorWithTypeNaming" FROM users"#)
        .fetch_one(&pool)
        .await
        .expect("Can query");
}

SQLx version

0.8.6

Enabled SQLx features

features = [ "postgres", "runtime-tokio", "tls-native-tls" ]

Database server and version

Postgres 16

Operating system

Windows

Rust version

rustc 1.90.0 (1159e78c4 2025-09-14)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions