Skip to content

Commit

Permalink
Merge pull request #75 from edharper01/master
Browse files Browse the repository at this point in the history
Support for parameters with long data types
  • Loading branch information
alexbrainman authored Aug 19, 2016
2 parents 2fd1af7 + fd440c1 commit b78637d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions mssql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,7 @@ var paramTypeTests = []struct {
{"datetime overflow", "datetime", time.Date(2013, 9, 9, 14, 07, 15, 123e6, time.Local)},
// binary blobs
{"small blob", "varbinary", make([]byte, 1)},
{"very large blob", "varbinary(max)", make([]byte, 100000)},
{"7999 large image", "image", make([]byte, 7999)},
{"8000 large image", "image", make([]byte, 8000)},
{"8001 large image", "image", make([]byte, 8001)},
Expand Down
12 changes: 12 additions & 0 deletions param.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,18 @@ func ExtractParameters(h api.SQLHSTMT) ([]Parameter, error) {
continue
}
p.isDescribed = true
// SQL Server MAX types (varchar(max), nvarchar(max),
// varbinary(max) are identified by size = 0
if p.Size == 0 {
switch p.SQLType {
case api.SQL_VARBINARY:
p.SQLType = api.SQL_LONGVARBINARY
case api.SQL_VARCHAR:
p.SQLType = api.SQL_LONGVARCHAR
case api.SQL_WVARCHAR:
p.SQLType = api.SQL_WLONGVARCHAR
}
}
}
return ps, nil
}

0 comments on commit b78637d

Please sign in to comment.