File tree Expand file tree Collapse file tree 5 files changed +16
-9
lines changed Expand file tree Collapse file tree 5 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -46,8 +46,9 @@ _______
46
46
NoSQLHandle.table_request followed by TableResult.wait_for_completion.
47
47
* Change PreparedStatement.set_variable method to support both name and position
48
48
variables.
49
- * Enhance handling of TIMESTAMP types to consider a datetime instance with
50
- and explicit timezone.
49
+ * Enhance handling of TIMESTAMP types to better handle a datetime instance with
50
+ an explicit timezone. By default fields of type TIMESTAMP returned by the system
51
+ are represented by a "naive" (not timezone aware) datetime object in the timezone UTC.
51
52
52
53
Fixed
53
54
_____
Original file line number Diff line number Diff line change @@ -70,5 +70,7 @@ Timestamp in Borneo
70
70
As mentioned above *Timestamp * fields are managed internally as UTC time. If a
71
71
timezone is supplied when setting a *Timestamp *, either as a string or as a
72
72
Python datetime object, it will be honored. The value will be converted to UTC
73
- internally and will be in UTC when returned in a row. If no timezone is
74
- supplied, python datetime instances and time strings are treated as UTC.
73
+ internally and will be in UTC when returned in a row. Although they are represented
74
+ in UTC returned datetime objects will be "naive" as described by Python documentation.
75
+ On input, if no timezone is supplied, python datetime instances and time strings are
76
+ treated as UTC.
Original file line number Diff line number Diff line change @@ -362,9 +362,9 @@ def read_bytearray_with_int(bis):
362
362
363
363
@staticmethod
364
364
def read_datetime (bis ):
365
- # Deserialize a datetime value.
366
- return parser . parse ( BinaryProtocol . read_string ( bis )). replace (
367
- tzinfo = tz . UTC )
365
+ # Deserialize a datetime value. Timezone is UTC, object is naive, not
366
+ # timezone aware
367
+ return parser . parse ( BinaryProtocol . read_string ( bis ) )
368
368
369
369
@staticmethod
370
370
def read_decimal (bis ):
Original file line number Diff line number Diff line change @@ -196,7 +196,11 @@ def testPutNormal(self):
196
196
self .row ['fld_time' ] = (
197
197
self .row ['fld_time' ].replace (tzinfo = tz .gettz ('EST' )))
198
198
self .put_request .set_value (self .row ).set_ttl (self .ttl )
199
- self .row ['fld_time' ] = self .row ['fld_time' ].astimezone (tz .UTC )
199
+ # the replace(tzinfo=None) at the end makes the object a "naive"
200
+ # datetime. Without that there is a datetime comparison problem in
201
+ # check_get_result()
202
+ self .row ['fld_time' ] = (
203
+ self .row ['fld_time' ].astimezone (tz .UTC ).replace (tzinfo = None ))
200
204
result = self .handle .put (self .put_request )
201
205
expect_expiration = self .ttl .to_expiration_time (
202
206
int (round (time () * 1000 )))
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ def get_row(with_sid=True):
157
157
row ['fld_bool' ] = True
158
158
row ['fld_str' ] = '{"name": u1, "phone": null}'
159
159
row ['fld_bin' ] = bytearray (pack ('>i' , 4 ))
160
- row ['fld_time' ] = datetime .now (tz . UTC )
160
+ row ['fld_time' ] = datetime .now ()
161
161
row ['fld_num' ] = Decimal (5 )
162
162
location = OrderedDict ()
163
163
location ['type' ] = 'point'
You can’t perform that action at this time.
0 commit comments