Skip to content

query_as! macro does not work with rename_all = "camelCase" #2816

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

Closed
Niels-Be opened this issue Oct 11, 2023 · 1 comment
Closed

query_as! macro does not work with rename_all = "camelCase" #2816

Niels-Be opened this issue Oct 11, 2023 · 1 comment
Labels

Comments

@Niels-Be
Copy link

Bug Description

query_as! macro does not work with rename_all = "camelCase"

Minimal Reproduction

#[derive(Debug, FromRow, Clone)]
#[sqlx(rename_all = "camelCase")]
struct Model {
  pub some_name: String;
}

// CREATE TABLE ModelTable ( someName TEXT NOT NULL );

sqlx::query_as!(Model, "SELECT * FROM ModelTable").fetch_all(&pool);
// Error: struct `Model` has no field named `someName`
//  help: a field with a similar name exists: `some_name`

While the error message is technically correct, just using query_as without the macro works fine as expected.

Info

  • SQLx version: 0.6.3
  • SQLx features enabled: runtime-tokio-rustls, sqlite
  • Database server and version: sqlite3
  • Operating system: linux
  • rustc --version: rustc 1.72.0-nightly (46514218f 2023-06-20)
@Niels-Be Niels-Be added the bug label Oct 11, 2023
@abonander
Copy link
Collaborator

query_as! is not currently aware of the FromRow derive. See the docs: https://docs.rs/sqlx/latest/sqlx/macro.query_as.html

This macro does not use FromRow; in fact, no trait implementations are required at all, though this may change in future versions.

#514 for details.

@abonander abonander closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2023
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