1
0
Fork 0
forked from forgejo/forgejo

Update to latest mssqldriver (#7613)

* New driver does not tolerate USE - handle this by closing db and reopening db in the new dbname
This commit is contained in:
zeripath 2019-07-26 05:10:20 +01:00 committed by GitHub
parent bebc6a3c77
commit 78e5317242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
31 changed files with 2376 additions and 598 deletions

View file

@ -23,7 +23,7 @@ func (d *Driver) OpenConnection(dsn string) (*Conn, error) {
return d.open(context.Background(), dsn)
}
func (c *Conn) prepareCopyIn(query string) (_ driver.Stmt, err error) {
func (c *Conn) prepareCopyIn(ctx context.Context, query string) (_ driver.Stmt, err error) {
config_json := query[11:]
bulkconfig := serializableBulkConfig{}
@ -32,7 +32,7 @@ func (c *Conn) prepareCopyIn(query string) (_ driver.Stmt, err error) {
return
}
bulkcopy := c.CreateBulk(bulkconfig.TableName, bulkconfig.ColumnsName)
bulkcopy := c.CreateBulkContext(ctx, bulkconfig.TableName, bulkconfig.ColumnsName)
bulkcopy.Options = bulkconfig.Options
ci := &copyin{
@ -61,12 +61,12 @@ func (ci *copyin) NumInput() int {
}
func (ci *copyin) Query(v []driver.Value) (r driver.Rows, err error) {
return nil, errors.New("ErrNotSupported")
panic("should never be called")
}
func (ci *copyin) Exec(v []driver.Value) (r driver.Result, err error) {
if ci.closed {
return nil, errors.New("errCopyInClosed")
return nil, errors.New("copyin query is closed")
}
if len(v) == 0 {