Skip to content

Commit

Permalink
Adding one more spot + test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Oct 31, 2024
1 parent dbd10f4 commit 266c6e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions clients/shared/default_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ func DefaultValue(column columns.Column, dialect sql.Dialect) (any, error) {
}

return sql.QuoteLiteral(_time.Format(ext.PostgresDateFormat)), nil
case typing.TimestampNTZ.Kind:
_time, err := ext.ParseTimestampNTZFromInterface(column.DefaultValue())
if err != nil {
return "", fmt.Errorf("failed to cast colVal as time.Time, colVal: '%v', err: %w", column.DefaultValue(), err)
}

return sql.QuoteLiteral(_time.Format(ext.RFC3339NoTZ)), nil
case typing.ETime.Kind:
if err := column.KindDetails.EnsureExtendedTimeDetails(); err != nil {
return nil, err
Expand Down
5 changes: 5 additions & 0 deletions clients/shared/default_value_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ func TestColumn_DefaultValue(t *testing.T) {
col: columns.NewColumnWithDefaultValue("", typing.Date, birthdayDateTime),
expectedValue: "'2022-09-06'",
},
{
name: "timestamp_ntz",
col: columns.NewColumnWithDefaultValue("", typing.TimestampNTZ, birthdayDateTime),
expectedValue: "'2022-09-06T03:19:24.942'",
},
{
name: "time",
col: columns.NewColumnWithDefaultValue("", timeKind, birthdayDateTime),
Expand Down

0 comments on commit 266c6e9

Please sign in to comment.