-
Notifications
You must be signed in to change notification settings - Fork 14
bug: fix year formatting in spanner::Date #1085
bug: fix year formatting in spanner::Date #1085
Conversation
The year is required to be 0-padded to 4 digits, the month and date padding seems to be optional. Introduce a new integration test to verify data types can be written and read back.
Codecov Report
@@ Coverage Diff @@
## master #1085 +/- ##
=========================================
- Coverage 92.02% 91.72% -0.3%
=========================================
Files 163 164 +1
Lines 11995 12022 +27
=========================================
- Hits 11038 11027 -11
- Misses 957 995 +38
Continue to review full report at Codecov.
|
@@ -25,7 +25,7 @@ namespace internal { | |||
|
|||
std::string DateToString(Date d) { | |||
std::array<char, sizeof "-9223372036854775808-01-01"> buf; | |||
std::snprintf(buf.data(), buf.size(), "%" PRId64 "-%02d-%02d", d.year(), | |||
std::snprintf(buf.data(), buf.size(), "%04" PRId64 "-%02d-%02d", d.year(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no problem.
"INSERT INTO DataTypes (Id, DateValue, StringValue) " | ||
"VALUES(@id, @date, @event)", | ||
{{"id", Value("ReadWriteDate-1")}, | ||
{"date", Value(Date(161, 3, 8))}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should add a "> 9999" case to see how they handle their "YYYY: Four-digit year" edict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything over 9999 results in an error. That is consistent with the documentation; which says the valid range is 0001-01-01
to 9999-12-31
…p-spanner#1085) The year is required to be 0-padded to 4 digits, the month and date padding seems to be optional. Introduce a new integration test to verify data types can be written and read back.
The year is required to be 0-padded to 4 digits, the month and date
padding seems to be optional.
Introduce a new integration test to verify data types can be written and
read back.
Fixes #1083
This change is