Skip to content

query_as AnyPool returns BLOB that can't be parsed into struct #3635

@Mellowchan

Description

@Mellowchan

Bug Description

Hello, I am trying to write database agnostic application that would support Postgresql and Mysql/Mariadb and SQLite with where database would be defined before run so I've choosen AnyPool for this.

So far queries with MySqlPool and PgPool alone work without any issues, but AnyPool returns BLOB that can't be parsed into struct that I work with later in my code.

Error message:

err = ColumnDecode {
    index: "\"locale_tag\"",
    source: "mismatched types; Rust type `alloc::string::String` is not compatible with SQL type `BLOB`",
}

Minimal Reproduction

pub async fn get_locales(Extension(db): Extension<AnyPool>) -> Result<Json<Value>, AppError> {
	let locales_query = sqlx::query_as::<_, Locales>(
		"SELECT locale_tag, locale_name, locale_img, enabled FROM locales ORDER BY locale_tag ASC",
	)
	.fetch_all(&db)
	.await
	.map_err(|err| {
		dbg!(err);
		AppError::InternalServerError
	})?;
// rest of the fn is not included here
}

#[derive(Serialize, Deserialize, sqlx::FromRow)]
pub struct Locales {
	pub locale_tag: String,
	pub locale_name: String,
	pub locale_img: String,
	pub enabled: bool,
}

Info

  • SQLx version: 0.8.2
  • SQLx features enabled: ["runtime-tokio-rustls", "postgres", "macros", "time", "json", "mysql", "any"]
  • Database server and version: MySQL (mariadb 10.11.10)
  • Operating system: NixOS 25.05 (Linux x86_64 6.6.63)
  • rustc --version: rustc 1.82.0 (f6e511eec 2024-10-15)

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