Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/tables/azure-data-tables/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 12.0.0b5 (Unreleased)

* Bumped minimum requirement of msrest from `0.6.10` to `0.6.19`.
* Added support for datetime entities with milliseconds

## 12.0.0b4 (2020-01-12)
* Fixes an [issue](https://github.com/Azure/azure-sdk-for-python/issues/15554) where `query_entities` kwarg `parameters` would not work with multiple parameters or with non-string parameters. This now works with multiple parameters and numeric, string, boolean, UUID, and datetime objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def _to_str(value):


def _to_utc_datetime(value):
return value.strftime("%Y-%m-%dT%H:%M:%SZ")
try:
return value.strftime("%Y-%m-%dT%H:%M:%S.%fZ")
except ValueError:
return value.strftime("%Y-%m-%dT%H:%M:%SZ")


def _encode_base64(data):
Expand Down
31 changes: 26 additions & 5 deletions sdk/tables/azure-data-tables/azure/data/tables/_deserialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,32 @@ def tzname(self, dt):

def _from_entity_datetime(value):
# Cosmos returns this with a decimal point that throws an error on deserialization
if value[-9:] == ".0000000Z":
value = value[:-9] + "Z"
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ").replace(
tzinfo=Timezone()
)
value = clean_up_dotnet_timestamps(value)

try:
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%fZ").replace(
tzinfo=Timezone()
)
except ValueError:
return datetime.datetime.strptime(value, "%Y-%m-%dT%H:%M:%SZ").replace(
tzinfo=Timezone()
)


def clean_up_dotnet_timestamps(value):
# .NET has more decimal places than Python supports in datetime objects, this truncates
# values after 6 decimal places.
value = value.split(".")
ms = ""
if len(value) == 2:
ms = value[-1].replace("Z", "")
if len(ms) > 6:
ms = ms[:6]
ms = ms + "Z"
return ".".join([value[0], ms])

return value[0]



def _from_entity_guid(value):
Expand Down
5 changes: 0 additions & 5 deletions sdk/tables/azure-data-tables/azure/data/tables/_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@ def _str(value):
return value.encode("utf-8")

return str(value)


else:
_str = str


def _to_utc_datetime(value):
return value.strftime("%Y-%m-%dT%H:%M:%SZ")


def _to_str(value):
return _str(value) if value is not None else None
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
interactions:
- request:
body: '{"TableName": "uttable97bd1223"}'
headers:
Accept:
- application/json;odata=minimalmetadata
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '32'
Content-Type:
- application/json;odata=nometadata
DataServiceVersion:
- '3.0'
Date:
- Mon, 22 Feb 2021 14:24:35 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 22 Feb 2021 14:24:35 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://fake_table_account.table.core.windows.net/Tables
response:
body:
string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#Tables/@Element","TableName":"uttable97bd1223"}'
headers:
cache-control:
- no-cache
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Mon, 22 Feb 2021 14:24:35 GMT
location:
- https://fake_table_account.table.core.windows.net/Tables('uttable97bd1223')
server:
- Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
x-content-type-options:
- nosniff
x-ms-version:
- '2019-02-02'
status:
code: 201
message: Created
- request:
body: '{"PartitionKey": "pk97bd1223", "[email protected]": "Edm.String",
"RowKey": "rk97bd1223", "[email protected]": "Edm.String", "age": 39, "sex":
"male", "[email protected]": "Edm.String", "married": true, "deceased": false,
"ratio": 3.1, "evenratio": 3.0, "large": 933311100, "Birthday": "1973-10-04T00:00:00.000000Z",
"[email protected]": "Edm.DateTime", "birthday": "1970-10-04T00:00:00.000000Z",
"[email protected]": "Edm.DateTime", "binary": "YmluYXJ5", "[email protected]":
"Edm.Binary", "other": 20, "clsid": "c9da6455-213d-42c9-9a79-3e9149a57833",
"[email protected]": "Edm.Guid", "milliseconds": "2011-11-04T00:05:23.283000Z",
"[email protected]": "Edm.DateTime"}'
headers:
Accept:
- application/json;odata=minimalmetadata
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '681'
Content-Type:
- application/json;odata=nometadata
DataServiceVersion:
- '3.0'
Date:
- Mon, 22 Feb 2021 14:24:35 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 22 Feb 2021 14:24:35 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://fake_table_account.table.core.windows.net/uttable97bd1223
response:
body:
string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable97bd1223/@Element","odata.etag":"W/\"datetime''2021-02-22T14%3A24%3A36.5672082Z''\"","PartitionKey":"pk97bd1223","RowKey":"rk97bd1223","Timestamp":"2021-02-22T14:24:36.5672082Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"[email protected]":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","[email protected]":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","[email protected]":"Edm.Binary","binary":"YmluYXJ5","other":20,"[email protected]":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833","[email protected]":"Edm.DateTime","milliseconds":"2011-11-04T00:05:23.283Z"}'
headers:
cache-control:
- no-cache
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Mon, 22 Feb 2021 14:24:36 GMT
etag:
- W/"datetime'2021-02-22T14%3A24%3A36.5672082Z'"
location:
- https://fake_table_account.table.core.windows.net/uttable97bd1223(PartitionKey='pk97bd1223',RowKey='rk97bd1223')
server:
- Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
x-content-type-options:
- nosniff
x-ms-version:
- '2019-02-02'
status:
code: 201
message: Created
- request:
body: null
headers:
Accept:
- application/json;odata=minimalmetadata
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
DataServiceVersion:
- '3.0'
Date:
- Mon, 22 Feb 2021 14:24:36 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 22 Feb 2021 14:24:36 GMT
x-ms-version:
- '2019-02-02'
method: GET
uri: https://fake_table_account.table.core.windows.net/uttable97bd1223(PartitionKey='pk97bd1223',RowKey='rk97bd1223')
response:
body:
string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable97bd1223/@Element","odata.etag":"W/\"datetime''2021-02-22T14%3A24%3A36.5672082Z''\"","PartitionKey":"pk97bd1223","RowKey":"rk97bd1223","Timestamp":"2021-02-22T14:24:36.5672082Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"[email protected]":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","[email protected]":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","[email protected]":"Edm.Binary","binary":"YmluYXJ5","other":20,"[email protected]":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833","[email protected]":"Edm.DateTime","milliseconds":"2011-11-04T00:05:23.283Z"}'
headers:
cache-control:
- no-cache
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Mon, 22 Feb 2021 14:24:36 GMT
etag:
- W/"datetime'2021-02-22T14%3A24%3A36.5672082Z'"
server:
- Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
x-content-type-options:
- nosniff
x-ms-version:
- '2019-02-02'
status:
code: 200
message: OK
- request:
body: null
headers:
Accept:
- application/json
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '0'
Date:
- Mon, 22 Feb 2021 14:24:36 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b5 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 22 Feb 2021 14:24:36 GMT
x-ms-version:
- '2019-02-02'
method: DELETE
uri: https://fake_table_account.table.core.windows.net/Tables('uttable97bd1223')
response:
body:
string: ''
headers:
cache-control:
- no-cache
content-length:
- '0'
date:
- Mon, 22 Feb 2021 14:24:36 GMT
server:
- Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
x-content-type-options:
- nosniff
x-ms-version:
- '2019-02-02'
status:
code: 204
message: No Content
version: 1
Loading