-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from ulule/fix/do-not-panic-when-formatting-a-…
…nil-valuer fix: don't panic when formatting a nil valuer
- Loading branch information
Showing
2 changed files
with
28 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ package builder_test | |
|
||
import ( | ||
"database/sql" | ||
"database/sql/driver" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
@@ -495,9 +496,29 @@ func TestInsert_Valuer(t *testing.T) { | |
NamedQuery: "INSERT INTO table (email, login) VALUES (:arg_1, :arg_2)", | ||
Args: []interface{}{"[email protected]", sql.NullInt64{}}, | ||
}, | ||
{ | ||
Name: "nil valuer", | ||
Builder: loukoum. | ||
Insert("table"). | ||
Columns("email", "login"). | ||
Values("[email protected]", (*valuer)(nil)), | ||
String: "INSERT INTO table (email, login) VALUES ('[email protected]', NULL)", | ||
Query: "INSERT INTO table (email, login) VALUES ($1, $2)", | ||
NamedQuery: "INSERT INTO table (email, login) VALUES (:arg_1, :arg_2)", | ||
Args: []interface{}{"[email protected]", (*valuer)(nil)}, | ||
}, | ||
}) | ||
} | ||
|
||
type valuer struct{} | ||
|
||
func (valuer) Value() (driver.Value, error) { | ||
return nil, nil | ||
} | ||
func (*valuer) Scan(src interface{}) error { | ||
return nil | ||
} | ||
|
||
func TestInsert_Set(t *testing.T) { | ||
RunBuilderTests(t, []BuilderTest{ | ||
{ | ||
|
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