Skip to content

Commit

Permalink
Merge pull request #9 from nakatamixi/fix/bytes-update
Browse files Browse the repository at this point in the history
fix UPDATE BYTES to default values
  • Loading branch information
daichirata committed Apr 8, 2020
2 parents 1e0a744 + a6873e8 commit 9b280ef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/hammer/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,10 @@ func (u Update) defaultValue() string {
return "false"
case spansql.Int64, spansql.Float64:
return "0"
case spansql.String, spansql.Bytes:
case spansql.String:
return "''"
case spansql.Bytes:
return "b''"
case spansql.Date:
return "'0001-01-01'"
case spansql.Timestamp:
Expand Down
4 changes: 4 additions & 0 deletions internal/hammer/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ func TestUpdate_SQL(t *testing.T) {
d: spansql.ColumnDef{Name: "test_column", Type: spansql.Type{Base: spansql.String}},
s: "UPDATE test_table SET test_column = '' WHERE test_column IS NULL",
},
{
d: spansql.ColumnDef{Name: "test_column", Type: spansql.Type{Base: spansql.Bytes}},
s: "UPDATE test_table SET test_column = b'' WHERE test_column IS NULL",
},
{
d: spansql.ColumnDef{Name: "test_column", Type: spansql.Type{Base: spansql.String, Array: true}},
s: "UPDATE test_table SET test_column = [] WHERE test_column IS NULL",
Expand Down

0 comments on commit 9b280ef

Please sign in to comment.