Skip to content

Commit

Permalink
add (previously failing) testcase for multiStatement + strict + insertId
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensayshi committed Jun 6, 2017
1 parent acdaa0b commit e59b980
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func runTestsWithMultiStatement(t *testing.T, dsn string, tests ...func(dbt *DBT
for _, test := range tests {
test(dbt)
dbt.db.Exec("DROP TABLE IF EXISTS test")
dbt.db.Exec("DROP TABLE IF EXISTS test2")
}
}

Expand All @@ -110,6 +111,7 @@ func runTests(t *testing.T, dsn string, tests ...func(dbt *DBTest)) {
defer db.Close()

db.Exec("DROP TABLE IF EXISTS test")
db.Exec("DROP TABLE IF EXISTS test2")

dsn2 := dsn + "&interpolateParams=true"
var db2 *sql.DB
Expand Down Expand Up @@ -137,13 +139,16 @@ func runTests(t *testing.T, dsn string, tests ...func(dbt *DBTest)) {
for _, test := range tests {
test(dbt)
dbt.db.Exec("DROP TABLE IF EXISTS test")
dbt.db.Exec("DROP TABLE IF EXISTS test2")
if db2 != nil {
test(dbt2)
dbt2.db.Exec("DROP TABLE IF EXISTS test")
dbt2.db.Exec("DROP TABLE IF EXISTS test2")
}
if db3 != nil {
test(dbt3)
dbt3.db.Exec("DROP TABLE IF EXISTS test")
dbt3.db.Exec("DROP TABLE IF EXISTS test2")
}
}
}
Expand Down Expand Up @@ -445,6 +450,14 @@ func TestFloat64Placeholder(t *testing.T) {
})
}

func TestMultiStatementStrict(t *testing.T) {
runTestsWithMultiStatement(t, dsn, func(dbt *DBTest) {
dbt.mustExec("CREATE TABLE test (id INT(11) UNSIGNED NOT NULL, PRIMARY KEY (id))")
dbt.mustExec("CREATE TABLE test2 (id INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (id))")
dbt.mustExec("INSERT INTO test VALUES (71398); INSERT INTO test2 VALUES (71398);")
})
}

func TestString(t *testing.T) {
runTests(t, dsn, func(dbt *DBTest) {
types := [6]string{"CHAR(255)", "VARCHAR(255)", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT"}
Expand Down

0 comments on commit e59b980

Please sign in to comment.