Skip to content

Commit

Permalink
internal/sqltest: skip NULL literals as row values
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m committed Mar 6, 2022
1 parent 3b8a69e commit d2aee24
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions sql/internal/sqltest/sqltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import (
)

// Rows converts MySQL/PostgreSQL table output to sql.Rows.
// All row values are parsed as text except the "nil" keyword. For example:
// All row values are parsed as text except the "nil" and NULL keywords.
// For example:
//
// +-------------+-------------+-------------+----------------+
// | column_name | column_type | is_nullable | column_default |
Expand Down Expand Up @@ -48,7 +49,9 @@ func Rows(table string) *sqlmock.Rows {
} else {
values := make([]driver.Value, nc)
for i, c := range columns {
if c != "" && c != "nil" {
switch c {
case "", "nil", "NULL":
default:
values[i] = c
}
}
Expand Down

0 comments on commit d2aee24

Please sign in to comment.