Skip to content

Commit 6ab8bed

Browse files
fix(spanner/spansql): fix invalid timestamp literal formats (#6077)
Co-authored-by: rahul2393 <rahulyadavsep92@gmail.com>
1 parent e823d8f commit 6ab8bed

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

spanner/spansql/parser.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,8 +3113,8 @@ var timestampFormats = []string{
31133113
"2006-01-02",
31143114
"2006-01-02 15:04:05",
31153115
"2006-01-02 15:04:05.000000",
3116-
"2006-01-02 15:04:05 -07:00",
3117-
"2006-01-02 15:04:05.000000 -07:00",
3116+
"2006-01-02 15:04:05-07:00",
3117+
"2006-01-02 15:04:05.000000-07:00",
31183118
}
31193119

31203120
var defaultLocation = func() *time.Location {

spanner/spansql/sql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ func (dl DateLiteral) addSQL(sb *strings.Builder) {
736736

737737
func (tl TimestampLiteral) SQL() string { return buildSQL(tl) }
738738
func (tl TimestampLiteral) addSQL(sb *strings.Builder) {
739-
fmt.Fprintf(sb, "TIMESTAMP '%s'", time.Time(tl).Format("2006-01-02 15:04:05.000000 -07:00"))
739+
fmt.Fprintf(sb, "TIMESTAMP '%s'", time.Time(tl).Format("2006-01-02 15:04:05.000000-07:00"))
740740
}
741741

742742
func (jl JSONLiteral) SQL() string { return buildSQL(jl) }

spanner/spansql/sql_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ func TestSQL(t *testing.T) {
556556
},
557557
{
558558
TimestampLiteral(time.Date(2014, time.September, 27, 12, 34, 56, 123456e3, latz)),
559-
`TIMESTAMP '2014-09-27 12:34:56.123456 -07:00'`,
559+
`TIMESTAMP '2014-09-27 12:34:56.123456-07:00'`,
560560
reparseExpr,
561561
},
562562
{

0 commit comments

Comments
 (0)