Closed

Description
Hi!
I noticed a naming collision when using actix-web and SQLx together. Basically, if I have an endpoint password
, the various routing macros will create a struct with name password
. In Rust, a structure name cannot be used as an identifier for a variable, which is exactly what happens when using the query!
macro with for example 'password' as a parameter. I don't exactly know how the macro works, so I sadly cannot give any suggestions on how to fix this.
Here's an example of the error I am getting when compiling:
error[E0308]: mismatched types
--> backend/src/auth.rs:11:8
|
11 | if sqlx::query!(
| ________^
12 | | r#"
13 | | SELECT * FROM users WHERE
14 | | uname = $1 AND
15 | | password = $2;
16 | | "#,
17 | | &payload.identifier,
18 | | &payload.password,
19 | | )
| | ^
| | |
| | expected struct `String`, found struct `password`
| | this expression has type `String`
| |_____`password` is interpreted as a unit struct, not a new binding
| help: introduce a new binding instead: `other_password`
...
63 | #[post("/password")]
| -------------------- unit struct defined here
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0308]: mismatched types
--> backend/src/auth.rs:11:8
|
11 | if sqlx::query!(
| ________^
12 | | r#"
13 | | SELECT * FROM users WHERE
14 | | uname = $1 AND
15 | | password = $2;
16 | | "#,
17 | | &payload.identifier,
18 | | &payload.password,
19 | | )
| |_____^ expected struct `String`, found struct `password`
I'm not looking for a workaround, just thought I'd let you know this was an issue.
Metadata
Metadata
Assignees
Labels
No labels