forked from go-pg/pg
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fixed
NULL
not being formatted for slices/maps.
When a query parameter was a nil slice or a nil map, the value `NULL` would not be appended to the query. Instead `'null'` would be appended to the query which is not correct. Resolves go-pg#1908
- Loading branch information
1 parent
4d138f1
commit be3aae4
Showing
2 changed files
with
35 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package types | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAppend(t *testing.T) { | ||
t.Run("null pointer", func(t *testing.T) { | ||
var a *struct{} | ||
result := Append(nil, a, 1) | ||
assert.Equal(t, "NULL", string(result)) | ||
}) | ||
|
||
t.Run("null map", func(t *testing.T) { | ||
var a map[string]int | ||
result := Append(nil, a, 1) | ||
assert.Equal(t, "NULL", string(result)) | ||
}) | ||
|
||
t.Run("null string array", func(t *testing.T) { | ||
var a []string | ||
result := Append(nil, a, 1) | ||
assert.Equal(t, "NULL", string(result)) | ||
}) | ||
} |