-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
bindvar for MSSQL #928
Comments
I did some digging around and found that in bind.go:
But db.DriverName() returns "azuresql", which means it gets "UNKNOWN" instead from func BindType. |
adding azuresql solved the problem, i.e. vi bind.go and:
So now this code works:
|
closing as #927 has been merged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
MSSQL bind vars doesn't seem to work properly without a workaround (will describe further down). The writeup at https://jmoiron.github.io/sqlx/ says
I tried Query, NamedQuery, and looks like ? is generated instead of @ for MSSQL, since the error is:
err=mssql: Incorrect syntax near '?'.
I also tried the example with sqlx.Named (since it's "named" the same as sql's Named) but that says it specifically uses the ? bind variable, and yes, it also threw the same incorrect syntax near '?' error.
[edit]
I also tried db.Rebind, but again, same problem:
again same error: mssql: Incorrect syntax near '?'
NB just realised I am using an azure SQL Server instance, maybe this makes a difference? azuread is from "github.com/microsoft/go-mssqldb/azuread"
To workaround this, I had to do something like:
Is there a better way to do this, or this is a known issue and correct solution?
The text was updated successfully, but these errors were encountered: