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

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

Open
moom-en opened this issue Jan 6, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@moom-en
Copy link

moom-en commented Jan 6, 2025

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
@moom-en moom-en added the bug Something isn't working label Jan 6, 2025
@moom-en moom-en 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 Jan 6, 2025
@moom-en moom-en 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 Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant