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

Update to latest changes in github.com/denisenkom/go-mssqldb #151

Closed
AlekSi opened this issue Apr 16, 2018 · 2 comments
Closed

Update to latest changes in github.com/denisenkom/go-mssqldb #151

AlekSi opened this issue Apr 16, 2018 · 2 comments
Assignees
Labels
Milestone

Comments

@AlekSi
Copy link
Member

AlekSi commented Apr 16, 2018

github.com/denisenkom/go-mssqldb recently implemented database/sql/driver.SessionResetter interface which broke our tests due to SET IDENTITY_INSERT used by them.

@AlekSi AlekSi added this to the v1.4.0 milestone Apr 16, 2018
AlekSi added a commit that referenced this issue Apr 16, 2018
@AlekSi AlekSi added the chore label Apr 16, 2018
@AlekSi
Copy link
Member Author

AlekSi commented Apr 16, 2018

@AlekseyMartynov May you take a look, please?

@AlekseyMartynov
Copy link
Collaborator

From debugging I understand that with SessionResetter, SET IDENTITY_INSERT must be called in each transaction (or even before each query?)

To satisfy this in tests, setIdentityInsert can be called immediately before and after Insert:

setIdentityInsert(s.T(), tx.Querier, "people", true)
s.NoError(tx.Insert(person))
setIdentityInsert(s.T(), tx.Querier, "people", false)

reform-db is more tricky. Specifically for test data in internal/test/sql, a possible solution is to combine all SQL in a single temporary file.

Interesting insight is that using one connection doesn't solve all problems:

reform/reform-db/main.go

Lines 56 to 59 in 161dee9

// Use single connection so various session-related variables work.
// For example: "PRAGMA foreign_keys" for SQLite3, "SET IDENTITY_INSERT" for MS SQL, etc.
sqlDB.SetMaxIdleConns(1)
sqlDB.SetMaxOpenConns(1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants