diff --git a/sdk/data/aztables/CHANGELOG.md b/sdk/data/aztables/CHANGELOG.md index 44276d10008f..2ac497ca9df3 100644 --- a/sdk/data/aztables/CHANGELOG.md +++ b/sdk/data/aztables/CHANGELOG.md @@ -12,6 +12,7 @@ ### Bugs Fixed * Fixed an issue that could cause `Client.NewListEntitiesPager` to skip pages in some cases. +* Fixed an issue that could cause unmarshaling empty time values to fail. ### Other Changes diff --git a/sdk/data/aztables/autorest.md b/sdk/data/aztables/autorest.md index cdfda8c8b550..32e5a1a13132 100644 --- a/sdk/data/aztables/autorest.md +++ b/sdk/data/aztables/autorest.md @@ -21,7 +21,7 @@ modelerfour: seal-single-value-enum-by-default: true directive: - - from: source-file-go + - from: zz_table_client.go where: $ transform: >- return $. @@ -34,6 +34,11 @@ directive: replace(/= client\.mergeEntityCreateRequest\(/, `= client.MergeEntityCreateRequest(`). replace(/= client\.updateEntityCreateRequest\(/, `= client.UpdateEntityCreateRequest(`). replace(/if rowKey == "" \{\s*.*\s*\}\s*/g, ``); + - from: + - zz_time_rfc1123.go + - zz_time_rfc3339.go + where: $ + transform: return $.replace(/UnmarshalText\(data\s+\[\]byte\)\s+(?:error|\(error\))\s+\{\s/g, `UnmarshalText(data []byte) error {\n\tif len(data) == 0 {\n\t\treturn nil\n\t}\n`); ``` ### Go multi-api diff --git a/sdk/data/aztables/internal/zz_time_rfc1123.go b/sdk/data/aztables/internal/zz_time_rfc1123.go index 39577c893718..3d4e0f8135c1 100644 --- a/sdk/data/aztables/internal/zz_time_rfc1123.go +++ b/sdk/data/aztables/internal/zz_time_rfc1123.go @@ -36,6 +36,9 @@ func (t *dateTimeRFC1123) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC1123) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } p, err := time.Parse(time.RFC1123, string(data)) *t = dateTimeRFC1123(p) return err diff --git a/sdk/data/aztables/internal/zz_time_rfc3339.go b/sdk/data/aztables/internal/zz_time_rfc3339.go index 511119b93a7b..96c08aad5019 100644 --- a/sdk/data/aztables/internal/zz_time_rfc3339.go +++ b/sdk/data/aztables/internal/zz_time_rfc3339.go @@ -44,6 +44,9 @@ func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano