Skip to content

Parameters bound using QueryBuilder, in mssql or for ? Cause error #11

Closed

Description

@moom-en

Bug Description

when using QueryBuilder to perform dynamic SQL binding, the corresponding parameter placeholders are generated incorrectly
通过 QueryBuilder 进行动态 sql 绑定时,生成对应的参数占位符不正确

let id = 100;
let mut builder = QueryBuilder::<Mssql>::new("SELECT * FROM table ");
builder.push("WHERE id=").push_bind(id)
  .push(" AND name=").push_bind("test");
let sql = builder.build().sql();
println!("生成的sql:{}", sql);
-------
生成的sql:SELECT * FROM table WHERE id=? AND name=?

correct result (正确结果应该为):SELECT * FROM table WHERE id=@p1 AND name=@p2

Info

  • SQLx version: 0.6.38
  • SQLx features enabled: mssql、runtime-tokio-native-tls
  • Database server and version: Mssql 2022
  • Operating system: windows 10
  • rustc --version: 1.83.0

Activity

  1. added
    bug
    on Jan 6, 2025
  2. changed the title [-]Parameters bound using QueryBuilder, in mssql or for ? Cause error[/-] [+]SQLx-oldapi Parameters bound using QueryBuilder, in mssql or for ? Cause error[/+] on Jan 6, 2025
  3. changed the title [-]SQLx-oldapi Parameters bound using QueryBuilder, in mssql or for ? Cause error[/-] [+]Parameters bound using QueryBuilder, in mssql or for ? Cause error[/+] on Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions