-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fix incorrect syntax errors for MSSQL driver #227
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reporting the issue and providing a fix!
Looks like only @pN
and named parameters are officially supported now. ?
replacement is deprecated.
References:
- https://github.com/denisenkom/go-mssqldb#query-parameter-token-replace-driver-mssql
- https://github.com/denisenkom/go-mssqldb#parameters
Could you add tests to prevent a regression?
My poor Windows PC with docker-machine isn't too fond of running the tests. I'll fire up a VM and look into it! |
The existing tests will catch regressions here. They were passing because the connection was opened with the deprecated 'mssql' driver instead of the 'sqlserver' one. The 'mssql' driver still uses If the driver is inadvertently changed back to 'mssql', the tests will fail because it can't handle the |
Pull Request Test Coverage Report for Build 421
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for investigating!
The existing tests will catch regressions here. They were passing because the connection was opened with the deprecated 'mssql' driver instead of the 'sqlserver' one. The 'mssql' driver still uses ? parameters and is not recommended to use.
If the driver is inadvertently changed back to 'mssql', the tests will fail because it can't handle the @pn notations and the lock tests fail.
Uggghhhh, different behavior based on the driver name is quite annoying...
Could you update the tests to test against both driver names using t.Run()
(e.g. subtests)?
@dhui You're right. Because of
Which would you think is better? I'm leaning towards option 1 currently. Can always remove the support once the upstream driver removes their support. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually leaning towards option 2 since we just added support for MS SQL Server. e.g. we don't need to support older versions yet. Any users using mssql
would have to migrate their app to use sqlserver
.
I think we should:
- Document support for only
sqlserver
in both the DB driver README and theWithInstance()
docs. - Register DB driver with only
sqlserver
to reduce the potential for confusion. e.g. removedatabase.Register("mssql", &db)
Not sure what's going on with the tests here. Repeatedly seeing this error on unrelated tests:
followed by
for all the database images. |
Looks like MCR or TravisCI were being slow. |
@zhevron I'm also thinking that we should rename the driver to |
@dhui I think it's clearer which vendor it is with the driver name remaining as As for the tests, it was happening to several of the database drivers, so increasing the timeout in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doing the rename! Supporting only a single driver kept testing more simple.
Just one comment needs to be updated.
database/sqlserver/sqlserver.go
Outdated
SchemaName string | ||
} | ||
|
||
// MSSQL connection |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment needs to be updated as well
With the MSSQL driver recently merged in, I'm getting errors when running against my MSSQL 2017 instance:
MSSQL uses
@pN
syntax for parameters instead of?
.