Skip to content

About use query! and query_as! #2861

Closed as not planned
Closed as not planned
@moom-en

Description

@moom-en

Bug Description

let mut sql = String::from("select * from user");
// append sql content
...
let arr = sqlx::query!(sql.as_str()).fetch_all(pool).await?;(error: expected string literal)
but:
let arr = sqlx::query!("select * from user").fetch_all(pool).await?;(it's ok)

Minimal Reproduction

A small code snippet or a link to a Github repo or Gist, with instructions on reproducing the bug.

Info

  • SQLx version: 0.7.2
  • SQLx features enabled: runtime-tokio、mysql
  • Database server and version: MySQL
  • Operating system: windows 10
  • rustc --version: 1.73.0

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