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

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

Open
Mellowchan opened this issue Dec 12, 2024 · 1 comment
Open

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

Mellowchan opened this issue Dec 12, 2024 · 1 comment
Labels

Comments

@Mellowchan
Copy link

Mellowchan commented Dec 12, 2024

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)
@Mellowchan Mellowchan added the bug label Dec 12, 2024
@joeydewaal
Copy link
Contributor

Probably caused by #3387

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

No branches or pull requests

2 participants