Skip to content

Commit

Permalink
Fix default value of timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
daichirata committed Sep 16, 2021
1 parent 4abde3b commit e932842
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/hammer/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (u Update) defaultValue() string {
case spansql.Date:
return "'0001-01-01'"
case spansql.Timestamp:
return "'0001-01-01 00:00:00'"
return "'0001-01-01T00:00:00Z'"
default:
return "''"
}
Expand Down
2 changes: 1 addition & 1 deletion internal/hammer/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func TestUpdate_SQL(t *testing.T) {
},
{
d: spansql.ColumnDef{Name: "test_column", Type: spansql.Type{Base: spansql.Timestamp}},
s: "UPDATE test_table SET test_column = '0001-01-01 00:00:00' WHERE test_column IS NULL",
s: "UPDATE test_table SET test_column = '0001-01-01T00:00:00Z' WHERE test_column IS NULL",
},
{
d: spansql.ColumnDef{Name: "order", Type: spansql.Type{Base: spansql.Int64}},
Expand Down
4 changes: 2 additions & 2 deletions internal/hammer/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ CREATE TABLE t1 (
) PRIMARY KEY(t1_1);
`,
expected: []string{
`UPDATE t1 SET t1_2 = '0001-01-01 00:00:00' WHERE t1_2 IS NULL`,
`UPDATE t1 SET t1_2 = '0001-01-01T00:00:00Z' WHERE t1_2 IS NULL`,
`ALTER TABLE t1 ALTER COLUMN t1_2 TIMESTAMP NOT NULL`,
},
},
Expand Down Expand Up @@ -225,7 +225,7 @@ CREATE TABLE t1 (
) PRIMARY KEY(t1_1);
`,
expected: []string{
`UPDATE t1 SET t1_2 = '0001-01-01 00:00:00' WHERE t1_2 IS NULL`,
`UPDATE t1 SET t1_2 = '0001-01-01T00:00:00Z' WHERE t1_2 IS NULL`,
`ALTER TABLE t1 ALTER COLUMN t1_2 TIMESTAMP NOT NULL`,
`ALTER TABLE t1 ALTER COLUMN t1_2 SET OPTIONS (allow_commit_timestamp = true)`,
},
Expand Down

0 comments on commit e932842

Please sign in to comment.