Last active
December 22, 2015 15:49
-
-
Save jstemmer/6494889 to your computer and use it in GitHub Desktop.
ODBC sql parameter testcases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var paramTests = []struct { | |
description string | |
sqlType string | |
value interface{} | |
}{ | |
{"empty string", "varchar(10)", ""}, | |
{"NULL for TEXT", "text", nil}, | |
{"large string value", "text", strings.Repeat("a", 10000)}, | |
{"datetime overflow", "datetime", time.Date(2013, 9, 9, 14, 07, 15, 123, time.UTC)}, | |
} | |
func TestMSSQLParamTests(t *testing.T) { | |
db, sc, err := mssqlConnect() | |
if err != nil { | |
t.Fatal(err) | |
} | |
defer closeDB(t, db, sc, sc) | |
for _, test := range paramTests { | |
db.Exec("drop table dbo.temp") | |
exec(t, db, fmt.Sprintf("create table dbo.temp(v %s)", test.sqlType)) | |
_, err = db.Exec("insert into dbo.temp(v) values(?)", test.value) | |
if err != nil { | |
t.Errorf("%s test failed: %s", test.description, err) | |
} | |
} | |
exec(t, db, "drop table dbo.temp") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== RUN TestMSSQLParamTests | |
--- FAIL: TestMSSQLParamTests (0.01 seconds) | |
mssql_test.go:1106: empty string test failed: SQLExecute: {07002} [Microsoft][SQL Server Native Client 10.0]COUNT field incorrect or syntax error | |
mssql_test.go:1106: NULL for TEXT test failed: SQLExecute: {22018} [Microsoft][SQL Server Native Client 10.0][SQL Server]Operand type clash: bit is incompatible with text | |
{42000} [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement(s) could not be prepared. | |
mssql_test.go:1106: large string value test failed: SQLExecute: {07002} [Microsoft][SQL Server Native Client 10.0]COUNT field incorrect or syntax error | |
mssql_test.go:1106: datetime overflow test failed: SQLExecute: {22008} [Microsoft][SQL Server Native Client 10.0]Datetime field overflow. Fractional second precision exceeds the scale specified in the parameter binding. | |
FAIL | |
exit status 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== RUN TestMSSQLParamTests | |
--- FAIL: TestMSSQLParamTests (0.02 seconds) | |
mssql_test.go:1106: empty string test failed: SQLExecute: {07002} [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error | |
mssql_test.go:1106: NULL for TEXT test failed: SQLExecute: {22018} [Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: bit is incompatible with text | |
{42000} [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared. | |
mssql_test.go:1106: large string value test failed: SQLExecute: {07002} [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error | |
mssql_test.go:1106: datetime overflow test failed: SQLExecute: {22008} [Microsoft][ODBC SQL Server Driver]Datetime field overflow | |
FAIL | |
exit status 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment