From 1e0e68350a5d22f7e55fab05f4c8a8cb0de91239 Mon Sep 17 00:00:00 2001 From: Daniel Getu Date: Mon, 29 Aug 2022 22:58:32 +0000 Subject: [PATCH 1/5] Fix filter encoding for Date objects --- ...cording_should_filter_dates_correctly.json | 288 ++++++++++++++++++ ...cording_should_filter_dates_correctly.json | 234 ++++++++++++++ sdk/tables/data-tables/src/odata.ts | 12 +- .../test/public/tableclient.spec.ts | 48 +++ 4 files changed, 580 insertions(+), 2 deletions(-) create mode 100644 sdk/tables/data-tables/recordings/browsers/tableclient_listentities/recording_should_filter_dates_correctly.json create mode 100644 sdk/tables/data-tables/recordings/node/tableclient_listentities/recording_should_filter_dates_correctly.json diff --git a/sdk/tables/data-tables/recordings/browsers/tableclient_listentities/recording_should_filter_dates_correctly.json b/sdk/tables/data-tables/recordings/browsers/tableclient_listentities/recording_should_filter_dates_correctly.json new file mode 100644 index 000000000000..0565f0ebd7bf --- /dev/null +++ b/sdk/tables/data-tables/recordings/browsers/tableclient_listentities/recording_should_filter_dates_correctly.json @@ -0,0 +1,288 @@ +{ + "Entries": [ + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Content-Length": "38", + "Content-Type": "application/json;odata=nometadata", + "dataserviceversion": "3.0", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", + "x-ms-client-request-id": "0fa9f00f-86d5-46ab-9710-be6212b8a4b9", + "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "tableClientTestbrowser" + }, + "StatusCode": 409, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Tue, 30 Aug 2022 21:15:43 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "0fa9f00f-86d5-46ab-9710-be6212b8a4b9", + "x-ms-request-id": "627c9f2c-b002-0109-07b5-bc215f000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.error": { + "code": "TableAlreadyExists", + "message": { + "lang": "en-US", + "value": "The table specified already exists.\nRequestId:627c9f2c-b002-0109-07b5-bc215f000000\nTime:2022-08-30T21:15:43.4786718Z" + } + } + } + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Content-Length": "102", + "Content-Type": "application/json;odata=nometadata", + "dataserviceversion": "3.0", + "prefer": "return-no-content", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", + "x-ms-client-request-id": "44353b18-1e94-47b8-b568-890117408f7e", + "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "p1", + "RowKey": "r1", + "date": "2019-07-10T18:59:59.999Z", + "date@odata.type": "Edm.DateTime" + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r1\u0027)", + "Date": "Tue, 30 Aug 2022 21:15:43 GMT", + "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A43.5016577Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r1\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "44353b18-1e94-47b8-b568-890117408f7e", + "x-ms-request-id": "627c9f39-b002-0109-11b5-bc215f000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Content-Length": "102", + "Content-Type": "application/json;odata=nometadata", + "dataserviceversion": "3.0", + "prefer": "return-no-content", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", + "x-ms-client-request-id": "adf96798-1c82-453a-b0db-343e946874b5", + "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "p1", + "RowKey": "r2", + "date": "2019-07-10T19:00:00.000Z", + "date@odata.type": "Edm.DateTime" + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r2\u0027)", + "Date": "Tue, 30 Aug 2022 21:15:43 GMT", + "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A43.5086536Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r2\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "adf96798-1c82-453a-b0db-343e946874b5", + "x-ms-request-id": "627c9f3c-b002-0109-14b5-bc215f000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Content-Length": "102", + "Content-Type": "application/json;odata=nometadata", + "dataserviceversion": "3.0", + "prefer": "return-no-content", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", + "x-ms-client-request-id": "79430820-d373-4fae-8dcb-3bc067e2aaac", + "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "p1", + "RowKey": "r3", + "date": "2019-07-10T19:00:00.001Z", + "date@odata.type": "Edm.DateTime" + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r3\u0027)", + "Date": "Tue, 30 Aug 2022 21:15:43 GMT", + "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A43.5156496Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r3\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "79430820-d373-4fae-8dcb-3bc067e2aaac", + "x-ms-request-id": "627c9f3f-b002-0109-17b5-bc215f000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser()?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval\u0026$filter=date%20lt%20datetime%272019-07-10T19%3A00%3A00.000Z%27", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "dataserviceversion": "3.0", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", + "x-ms-client-request-id": "254903a1-cca8-439b-9aba-b25279b8c276", + "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Tue, 30 Aug 2022 21:15:43 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "254903a1-cca8-439b-9aba-b25279b8c276", + "x-ms-request-id": "627c9f43-b002-0109-1bb5-bc215f000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#tableClientTestbrowser", + "value": [ + { + "odata.etag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A43.5016577Z\u0027\u0022", + "PartitionKey": "p1", + "RowKey": "r1", + "Timestamp": "2022-08-30T21:15:43.5016577Z", + "date@odata.type": "Edm.DateTime", + "date": "2019-07-10T18:59:59.999Z" + } + ] + } + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027tableClientTestbrowser\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "en-US", + "Referer": "http://localhost:9876/", + "sec-ch-ua": "", + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": "", + "Sec-Fetch-Dest": "empty", + "Sec-Fetch-Mode": "cors", + "Sec-Fetch-Site": "same-site", + "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", + "x-ms-client-request-id": "70ef2ddb-a6fb-45b5-9a26-388ee712753a", + "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Tue, 30 Aug 2022 21:15:43 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "70ef2ddb-a6fb-45b5-9a26-388ee712753a", + "x-ms-request-id": "627c9f46-b002-0109-1eb5-bc215f000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/tables/data-tables/recordings/node/tableclient_listentities/recording_should_filter_dates_correctly.json b/sdk/tables/data-tables/recordings/node/tableclient_listentities/recording_should_filter_dates_correctly.json new file mode 100644 index 000000000000..a61ff7eb99ac --- /dev/null +++ b/sdk/tables/data-tables/recordings/node/tableclient_listentities/recording_should_filter_dates_correctly.json @@ -0,0 +1,234 @@ +{ + "Entries": [ + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip,deflate", + "Content-Length": "35", + "Content-Type": "application/json;odata=nometadata", + "DataServiceVersion": "3.0", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", + "x-ms-client-request-id": "277dc5ae-0299-4b11-a017-5f971e317d03", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "TableName": "tableClientTestnode" + }, + "StatusCode": 409, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Tue, 30 Aug 2022 21:15:33 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "277dc5ae-0299-4b11-a017-5f971e317d03", + "x-ms-request-id": "544a1621-1002-0020-4ab5-bce126000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.error": { + "code": "TableAlreadyExists", + "message": { + "lang": "en-US", + "value": "The table specified already exists.\nRequestId:544a1621-1002-0020-4ab5-bce126000000\nTime:2022-08-30T21:15:33.9314811Z" + } + } + } + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestnode?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip,deflate", + "Content-Length": "102", + "Content-Type": "application/json;odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", + "x-ms-client-request-id": "740f412c-ea19-4bae-9ef8-9bff21f9f5c4", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "p1", + "RowKey": "r1", + "date": "2019-07-10T18:59:59.999Z", + "date@odata.type": "Edm.DateTime" + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r1\u0027)", + "Date": "Tue, 30 Aug 2022 21:15:33 GMT", + "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A33.9474727Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r1\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "740f412c-ea19-4bae-9ef8-9bff21f9f5c4", + "x-ms-request-id": "544a1629-1002-0020-50b5-bce126000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestnode?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip,deflate", + "Content-Length": "102", + "Content-Type": "application/json;odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", + "x-ms-client-request-id": "fff095c2-2643-439c-85de-23c821c57f3c", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "p1", + "RowKey": "r2", + "date": "2019-07-10T19:00:00.000Z", + "date@odata.type": "Edm.DateTime" + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r2\u0027)", + "Date": "Tue, 30 Aug 2022 21:15:33 GMT", + "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A33.9564678Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r2\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "fff095c2-2643-439c-85de-23c821c57f3c", + "x-ms-request-id": "544a162a-1002-0020-51b5-bce126000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestnode?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip,deflate", + "Content-Length": "102", + "Content-Type": "application/json;odata=nometadata", + "DataServiceVersion": "3.0", + "Prefer": "return-no-content", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", + "x-ms-client-request-id": "a68e404b-1b5c-4804-8fb8-5c5ea037bd23", + "x-ms-version": "2019-02-02" + }, + "RequestBody": { + "PartitionKey": "p1", + "RowKey": "r3", + "date": "2019-07-10T19:00:00.001Z", + "date@odata.type": "Edm.DateTime" + }, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r3\u0027)", + "Date": "Tue, 30 Aug 2022 21:15:33 GMT", + "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A33.9624639Z\u0027\u0022", + "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r3\u0027)", + "Preference-Applied": "return-no-content", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "a68e404b-1b5c-4804-8fb8-5c5ea037bd23", + "x-ms-request-id": "544a162c-1002-0020-53b5-bce126000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestnode()?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval\u0026$filter=date%20lt%20datetime%272019-07-10T19%3A00%3A00.000Z%27", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json;odata=minimalmetadata", + "Accept-Encoding": "gzip,deflate", + "DataServiceVersion": "3.0", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", + "x-ms-client-request-id": "942fb3d5-f474-4ed2-bb00-72f820bcb966", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", + "Date": "Tue, 30 Aug 2022 21:15:33 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "942fb3d5-f474-4ed2-bb00-72f820bcb966", + "x-ms-request-id": "544a162e-1002-0020-55b5-bce126000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": { + "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#tableClientTestnode", + "value": [ + { + "odata.etag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A33.9474727Z\u0027\u0022", + "PartitionKey": "p1", + "RowKey": "r1", + "Timestamp": "2022-08-30T21:15:33.9474727Z", + "date@odata.type": "Edm.DateTime", + "date": "2019-07-10T18:59:59.999Z" + } + ] + } + }, + { + "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027tableClientTestnode\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", + "RequestMethod": "DELETE", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip,deflate", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", + "x-ms-client-request-id": "bf99db6e-5fae-4513-92b6-d8f4f71fab3e", + "x-ms-version": "2019-02-02" + }, + "RequestBody": null, + "StatusCode": 204, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Tue, 30 Aug 2022 21:15:33 GMT", + "Server": [ + "Windows-Azure-Table/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "X-Content-Type-Options": "nosniff", + "x-ms-client-request-id": "bf99db6e-5fae-4513-92b6-d8f4f71fab3e", + "x-ms-request-id": "544a162f-1002-0020-56b5-bce126000000", + "x-ms-version": "2019-02-02" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/tables/data-tables/src/odata.ts b/sdk/tables/data-tables/src/odata.ts index 517f4e977ae6..8b2e52b0f2ce 100644 --- a/sdk/tables/data-tables/src/odata.ts +++ b/sdk/tables/data-tables/src/odata.ts @@ -7,7 +7,7 @@ function escapeQuotesIfString(input: unknown, previous: string): string | unknow if (typeof input === "string") { result = escapeQuotes(input); // check if we need to escape this literal - if (!previous.trim().endsWith("'")) { + if (previous !== "" && !previous.trim().endsWith("'")) { result = `'${result}'`; } } @@ -18,15 +18,23 @@ export function escapeQuotes(input: string): string { return input.replace(/'/g, "''"); } +function encodeDate(input: unknown): string | unknown { + return input instanceof Date ? `datetime'${input.toISOString()}'` : input; +} + /** * Escapes an odata filter expression to avoid errors with quoting string literals. + * Encodes Date objects. */ export function odata(strings: TemplateStringsArray, ...values: unknown[]): string { + const fixEncoding = (value: unknown, string: string) => { + return encodeDate(escapeQuotesIfString(value, string)); + }; const results = []; for (let i = 0; i < strings.length; i++) { results.push(strings[i]); if (i < values.length) { - results.push(escapeQuotesIfString(values[i], strings[i])); + results.push(fixEncoding(values[i], strings[i])); } } return results.join(""); diff --git a/sdk/tables/data-tables/test/public/tableclient.spec.ts b/sdk/tables/data-tables/test/public/tableclient.spec.ts index 01521a8e432e..5f39c53de738 100644 --- a/sdk/tables/data-tables/test/public/tableclient.spec.ts +++ b/sdk/tables/data-tables/test/public/tableclient.spec.ts @@ -192,6 +192,54 @@ describe(`TableClient`, () => { assert.deepEqual(String.fromCharCode(...all[0].foo), "Bar"); } }); + + it("should filter dates correctly", async function () { + await client.createTable(); + + const propertyName = "date"; + const comparisonDate = new Date("2019-07-10T12:00:00-0700"); + + try { + const entities = [ + { + partitionKey: "p1", + rowKey: "r1", + [propertyName]: new Date(comparisonDate.valueOf() - 1), + }, + { + partitionKey: "p1", + rowKey: "r2", + [propertyName]: comparisonDate, + }, + { + partitionKey: "p1", + rowKey: "r3", + [propertyName]: new Date(comparisonDate.valueOf() + 1), + }, + ]; + + for (const entity of entities) { + await client.createEntity(entity); + } + + const entityIterable = client.listEntities({ + queryOptions: { + filter: odata`${propertyName} lt ${comparisonDate}`, + }, + }); + + const responseDates = []; + for await (const entity of entityIterable) { + assert.property(entity, propertyName); + assert.typeOf(entity[propertyName], "Date"); + responseDates.push(entity[propertyName] as Date); + } + + assert.deepEqual(new Set(responseDates), new Set([entities[0][propertyName]])); + } finally { + await client.deleteTable(); + } + }); }); describe("createEntity, getEntity and delete", () => { From af9b7f058721f6168526a2aeca939c3d5764e40a Mon Sep 17 00:00:00 2001 From: Daniel Getu Date: Tue, 30 Aug 2022 21:49:42 +0000 Subject: [PATCH 2/5] Add changelog --- sdk/tables/data-tables/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/tables/data-tables/CHANGELOG.md b/sdk/tables/data-tables/CHANGELOG.md index 89714671970e..0bfc5b8d4bed 100644 --- a/sdk/tables/data-tables/CHANGELOG.md +++ b/sdk/tables/data-tables/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed +- Fix encoding for Date objects when filtering on a DateTime field [#23058](https://github.com/Azure/azure-sdk-for-js/pull/23058) + ### Other Changes ## 13.1.2 (2022-06-07) From b2993420b89302e4cdbf95c426b69b165c240bf7 Mon Sep 17 00:00:00 2001 From: Daniel Getu Date: Tue, 30 Aug 2022 21:51:50 +0000 Subject: [PATCH 3/5] Fix linter warning --- sdk/tables/data-tables/src/odata.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/tables/data-tables/src/odata.ts b/sdk/tables/data-tables/src/odata.ts index 8b2e52b0f2ce..e05ecf230197 100644 --- a/sdk/tables/data-tables/src/odata.ts +++ b/sdk/tables/data-tables/src/odata.ts @@ -27,7 +27,7 @@ function encodeDate(input: unknown): string | unknown { * Encodes Date objects. */ export function odata(strings: TemplateStringsArray, ...values: unknown[]): string { - const fixEncoding = (value: unknown, string: string) => { + const fixEncoding = (value: unknown, string: string): string | unknown => { return encodeDate(escapeQuotesIfString(value, string)); }; const results = []; From 66350443d862c659003398ad8b363fe9c35807ff Mon Sep 17 00:00:00 2001 From: Daniel Getu Date: Tue, 6 Sep 2022 18:08:58 +0000 Subject: [PATCH 4/5] Add odata test for improperly escaped property names --- sdk/tables/data-tables/test/internal/odata.spec.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sdk/tables/data-tables/test/internal/odata.spec.ts b/sdk/tables/data-tables/test/internal/odata.spec.ts index ce80ae4e87ea..8981a6790e91 100644 --- a/sdk/tables/data-tables/test/internal/odata.spec.ts +++ b/sdk/tables/data-tables/test/internal/odata.spec.ts @@ -38,4 +38,10 @@ describe("odata", () => { const testString = odata`test string ${testValue}`; assert.equal(testString, "test string '\"FooBar\"'"); }); + + it("should not escape property names unnecessarily", () => { + const testDate = new Date(1); + const testString = odata`test lt ${testDate}`; + assert.equal(testString, `test lt datetime'${testDate.toISOString()}'`); + }); }); From 71e9947b9f40ae8fcd172212876ecaf74430eacd Mon Sep 17 00:00:00 2001 From: Daniel Getu Date: Tue, 6 Sep 2022 18:25:56 +0000 Subject: [PATCH 5/5] Use shared table in table client tests --- ...cording_should_filter_dates_correctly.json | 128 +++--------------- ...cording_should_filter_dates_correctly.json | 118 ++++------------ .../test/public/tableclient.spec.ts | 70 +++++----- 3 files changed, 78 insertions(+), 238 deletions(-) diff --git a/sdk/tables/data-tables/recordings/browsers/tableclient_listentities/recording_should_filter_dates_correctly.json b/sdk/tables/data-tables/recordings/browsers/tableclient_listentities/recording_should_filter_dates_correctly.json index 0565f0ebd7bf..aa45b916b197 100644 --- a/sdk/tables/data-tables/recordings/browsers/tableclient_listentities/recording_should_filter_dates_correctly.json +++ b/sdk/tables/data-tables/recordings/browsers/tableclient_listentities/recording_should_filter_dates_correctly.json @@ -1,55 +1,5 @@ { "Entries": [ - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json;odata=minimalmetadata", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US", - "Content-Length": "38", - "Content-Type": "application/json;odata=nometadata", - "dataserviceversion": "3.0", - "Referer": "http://localhost:9876/", - "sec-ch-ua": "", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-site", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", - "x-ms-client-request-id": "0fa9f00f-86d5-46ab-9710-be6212b8a4b9", - "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", - "x-ms-version": "2019-02-02" - }, - "RequestBody": { - "TableName": "tableClientTestbrowser" - }, - "StatusCode": 409, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Tue, 30 Aug 2022 21:15:43 GMT", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "0fa9f00f-86d5-46ab-9710-be6212b8a4b9", - "x-ms-request-id": "627c9f2c-b002-0109-07b5-bc215f000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": { - "odata.error": { - "code": "TableAlreadyExists", - "message": { - "lang": "en-US", - "value": "The table specified already exists.\nRequestId:627c9f2c-b002-0109-07b5-bc215f000000\nTime:2022-08-30T21:15:43.4786718Z" - } - } - } - }, { "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", @@ -69,7 +19,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", - "x-ms-client-request-id": "44353b18-1e94-47b8-b568-890117408f7e", + "x-ms-client-request-id": "5ea894b7-b959-4070-a2a7-c6de78ea59a6", "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, @@ -84,8 +34,8 @@ "Cache-Control": "no-cache", "Content-Length": "0", "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r1\u0027)", - "Date": "Tue, 30 Aug 2022 21:15:43 GMT", - "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A43.5016577Z\u0027\u0022", + "Date": "Tue, 06 Sep 2022 18:24:25 GMT", + "ETag": "W/\u0022datetime\u00272022-09-06T18%3A24%3A25.8083421Z\u0027\u0022", "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r1\u0027)", "Preference-Applied": "return-no-content", "Server": [ @@ -93,8 +43,8 @@ "Microsoft-HTTPAPI/2.0" ], "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "44353b18-1e94-47b8-b568-890117408f7e", - "x-ms-request-id": "627c9f39-b002-0109-11b5-bc215f000000", + "x-ms-client-request-id": "5ea894b7-b959-4070-a2a7-c6de78ea59a6", + "x-ms-request-id": "22b598b7-8002-00f9-721d-c299a3000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null @@ -118,7 +68,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", - "x-ms-client-request-id": "adf96798-1c82-453a-b0db-343e946874b5", + "x-ms-client-request-id": "74adb1b9-4ff5-4789-b5ac-60c1693f0edd", "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, @@ -133,8 +83,8 @@ "Cache-Control": "no-cache", "Content-Length": "0", "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r2\u0027)", - "Date": "Tue, 30 Aug 2022 21:15:43 GMT", - "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A43.5086536Z\u0027\u0022", + "Date": "Tue, 06 Sep 2022 18:24:25 GMT", + "ETag": "W/\u0022datetime\u00272022-09-06T18%3A24%3A25.8283295Z\u0027\u0022", "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r2\u0027)", "Preference-Applied": "return-no-content", "Server": [ @@ -142,8 +92,8 @@ "Microsoft-HTTPAPI/2.0" ], "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "adf96798-1c82-453a-b0db-343e946874b5", - "x-ms-request-id": "627c9f3c-b002-0109-14b5-bc215f000000", + "x-ms-client-request-id": "74adb1b9-4ff5-4789-b5ac-60c1693f0edd", + "x-ms-request-id": "22b598ba-8002-00f9-731d-c299a3000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null @@ -167,7 +117,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", - "x-ms-client-request-id": "79430820-d373-4fae-8dcb-3bc067e2aaac", + "x-ms-client-request-id": "99ecc173-ae35-4779-9206-85b9d9eb06d8", "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, @@ -182,8 +132,8 @@ "Cache-Control": "no-cache", "Content-Length": "0", "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r3\u0027)", - "Date": "Tue, 30 Aug 2022 21:15:43 GMT", - "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A43.5156496Z\u0027\u0022", + "Date": "Tue, 06 Sep 2022 18:24:25 GMT", + "ETag": "W/\u0022datetime\u00272022-09-06T18%3A24%3A25.8343262Z\u0027\u0022", "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestbrowser(PartitionKey=\u0027p1\u0027,RowKey=\u0027r3\u0027)", "Preference-Applied": "return-no-content", "Server": [ @@ -191,8 +141,8 @@ "Microsoft-HTTPAPI/2.0" ], "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "79430820-d373-4fae-8dcb-3bc067e2aaac", - "x-ms-request-id": "627c9f3f-b002-0109-17b5-bc215f000000", + "x-ms-client-request-id": "99ecc173-ae35-4779-9206-85b9d9eb06d8", + "x-ms-request-id": "22b598bb-8002-00f9-741d-c299a3000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null @@ -213,7 +163,7 @@ "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-site", "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", - "x-ms-client-request-id": "254903a1-cca8-439b-9aba-b25279b8c276", + "x-ms-client-request-id": "342982ab-4c5d-4c68-bdbc-4cc69e6e6b07", "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", "x-ms-version": "2019-02-02" }, @@ -222,66 +172,30 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Tue, 30 Aug 2022 21:15:43 GMT", + "Date": "Tue, 06 Sep 2022 18:24:25 GMT", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], "Transfer-Encoding": "chunked", "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "254903a1-cca8-439b-9aba-b25279b8c276", - "x-ms-request-id": "627c9f43-b002-0109-1bb5-bc215f000000", + "x-ms-client-request-id": "342982ab-4c5d-4c68-bdbc-4cc69e6e6b07", + "x-ms-request-id": "22b598bc-8002-00f9-751d-c299a3000000", "x-ms-version": "2019-02-02" }, "ResponseBody": { "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#tableClientTestbrowser", "value": [ { - "odata.etag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A43.5016577Z\u0027\u0022", + "odata.etag": "W/\u0022datetime\u00272022-09-06T18%3A24%3A25.8083421Z\u0027\u0022", "PartitionKey": "p1", "RowKey": "r1", - "Timestamp": "2022-08-30T21:15:43.5016577Z", + "Timestamp": "2022-09-06T18:24:25.8083421Z", "date@odata.type": "Edm.DateTime", "date": "2019-07-10T18:59:59.999Z" } ] } - }, - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027tableClientTestbrowser\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "DELETE", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "en-US", - "Referer": "http://localhost:9876/", - "sec-ch-ua": "", - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": "", - "Sec-Fetch-Dest": "empty", - "Sec-Fetch-Mode": "cors", - "Sec-Fetch-Site": "same-site", - "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5058.0 Safari/537.36", - "x-ms-client-request-id": "70ef2ddb-a6fb-45b5-9a26-388ee712753a", - "x-ms-useragent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 OS/Linuxx86_64", - "x-ms-version": "2019-02-02" - }, - "RequestBody": null, - "StatusCode": 204, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "0", - "Date": "Tue, 30 Aug 2022 21:15:43 GMT", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "70ef2ddb-a6fb-45b5-9a26-388ee712753a", - "x-ms-request-id": "627c9f46-b002-0109-1eb5-bc215f000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": null } ], "Variables": {} diff --git a/sdk/tables/data-tables/recordings/node/tableclient_listentities/recording_should_filter_dates_correctly.json b/sdk/tables/data-tables/recordings/node/tableclient_listentities/recording_should_filter_dates_correctly.json index a61ff7eb99ac..2faf0fe987b6 100644 --- a/sdk/tables/data-tables/recordings/node/tableclient_listentities/recording_should_filter_dates_correctly.json +++ b/sdk/tables/data-tables/recordings/node/tableclient_listentities/recording_should_filter_dates_correctly.json @@ -1,46 +1,5 @@ { "Entries": [ - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "POST", - "RequestHeaders": { - "Accept": "application/json;odata=minimalmetadata", - "Accept-Encoding": "gzip,deflate", - "Content-Length": "35", - "Content-Type": "application/json;odata=nometadata", - "DataServiceVersion": "3.0", - "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", - "x-ms-client-request-id": "277dc5ae-0299-4b11-a017-5f971e317d03", - "x-ms-version": "2019-02-02" - }, - "RequestBody": { - "TableName": "tableClientTestnode" - }, - "StatusCode": 409, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Tue, 30 Aug 2022 21:15:33 GMT", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "Transfer-Encoding": "chunked", - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "277dc5ae-0299-4b11-a017-5f971e317d03", - "x-ms-request-id": "544a1621-1002-0020-4ab5-bce126000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": { - "odata.error": { - "code": "TableAlreadyExists", - "message": { - "lang": "en-US", - "value": "The table specified already exists.\nRequestId:544a1621-1002-0020-4ab5-bce126000000\nTime:2022-08-30T21:15:33.9314811Z" - } - } - } - }, { "RequestUri": "https://fakeaccountname.table.core.windows.net/tableClientTestnode?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", "RequestMethod": "POST", @@ -51,8 +10,8 @@ "Content-Type": "application/json;odata=nometadata", "DataServiceVersion": "3.0", "Prefer": "return-no-content", - "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", - "x-ms-client-request-id": "740f412c-ea19-4bae-9ef8-9bff21f9f5c4", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1089-azure)", + "x-ms-client-request-id": "254a2b6b-d647-4cc3-9151-2b0da799f3af", "x-ms-version": "2019-02-02" }, "RequestBody": { @@ -66,8 +25,8 @@ "Cache-Control": "no-cache", "Content-Length": "0", "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r1\u0027)", - "Date": "Tue, 30 Aug 2022 21:15:33 GMT", - "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A33.9474727Z\u0027\u0022", + "Date": "Tue, 06 Sep 2022 18:24:18 GMT", + "ETag": "W/\u0022datetime\u00272022-09-06T18%3A24%3A19.0162561Z\u0027\u0022", "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r1\u0027)", "Preference-Applied": "return-no-content", "Server": [ @@ -75,8 +34,8 @@ "Microsoft-HTTPAPI/2.0" ], "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "740f412c-ea19-4bae-9ef8-9bff21f9f5c4", - "x-ms-request-id": "544a1629-1002-0020-50b5-bce126000000", + "x-ms-client-request-id": "254a2b6b-d647-4cc3-9151-2b0da799f3af", + "x-ms-request-id": "7cf6a80d-8002-0032-461d-c29af6000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null @@ -91,8 +50,8 @@ "Content-Type": "application/json;odata=nometadata", "DataServiceVersion": "3.0", "Prefer": "return-no-content", - "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", - "x-ms-client-request-id": "fff095c2-2643-439c-85de-23c821c57f3c", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1089-azure)", + "x-ms-client-request-id": "1300d756-cf87-4f4e-84c5-444d6c688064", "x-ms-version": "2019-02-02" }, "RequestBody": { @@ -106,8 +65,8 @@ "Cache-Control": "no-cache", "Content-Length": "0", "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r2\u0027)", - "Date": "Tue, 30 Aug 2022 21:15:33 GMT", - "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A33.9564678Z\u0027\u0022", + "Date": "Tue, 06 Sep 2022 18:24:18 GMT", + "ETag": "W/\u0022datetime\u00272022-09-06T18%3A24%3A19.0352448Z\u0027\u0022", "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r2\u0027)", "Preference-Applied": "return-no-content", "Server": [ @@ -115,8 +74,8 @@ "Microsoft-HTTPAPI/2.0" ], "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "fff095c2-2643-439c-85de-23c821c57f3c", - "x-ms-request-id": "544a162a-1002-0020-51b5-bce126000000", + "x-ms-client-request-id": "1300d756-cf87-4f4e-84c5-444d6c688064", + "x-ms-request-id": "7cf6a810-8002-0032-471d-c29af6000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null @@ -131,8 +90,8 @@ "Content-Type": "application/json;odata=nometadata", "DataServiceVersion": "3.0", "Prefer": "return-no-content", - "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", - "x-ms-client-request-id": "a68e404b-1b5c-4804-8fb8-5c5ea037bd23", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1089-azure)", + "x-ms-client-request-id": "5b894d49-b4e4-4966-8ff7-15b232b652e1", "x-ms-version": "2019-02-02" }, "RequestBody": { @@ -146,8 +105,8 @@ "Cache-Control": "no-cache", "Content-Length": "0", "DataServiceId": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r3\u0027)", - "Date": "Tue, 30 Aug 2022 21:15:33 GMT", - "ETag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A33.9624639Z\u0027\u0022", + "Date": "Tue, 06 Sep 2022 18:24:18 GMT", + "ETag": "W/\u0022datetime\u00272022-09-06T18%3A24%3A19.0422417Z\u0027\u0022", "Location": "https://fakeaccountname.table.core.windows.net/tableClientTestnode(PartitionKey=\u0027p1\u0027,RowKey=\u0027r3\u0027)", "Preference-Applied": "return-no-content", "Server": [ @@ -155,8 +114,8 @@ "Microsoft-HTTPAPI/2.0" ], "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "a68e404b-1b5c-4804-8fb8-5c5ea037bd23", - "x-ms-request-id": "544a162c-1002-0020-53b5-bce126000000", + "x-ms-client-request-id": "5b894d49-b4e4-4966-8ff7-15b232b652e1", + "x-ms-request-id": "7cf6a811-8002-0032-481d-c29af6000000", "x-ms-version": "2019-02-02" }, "ResponseBody": null @@ -168,8 +127,8 @@ "Accept": "application/json;odata=minimalmetadata", "Accept-Encoding": "gzip,deflate", "DataServiceVersion": "3.0", - "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", - "x-ms-client-request-id": "942fb3d5-f474-4ed2-bb00-72f820bcb966", + "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1089-azure)", + "x-ms-client-request-id": "4a1d558b-9bfa-421d-a07a-b0f296b9f746", "x-ms-version": "2019-02-02" }, "RequestBody": null, @@ -177,57 +136,30 @@ "ResponseHeaders": { "Cache-Control": "no-cache", "Content-Type": "application/json; odata=minimalmetadata; streaming=true; charset=utf-8", - "Date": "Tue, 30 Aug 2022 21:15:33 GMT", + "Date": "Tue, 06 Sep 2022 18:24:18 GMT", "Server": [ "Windows-Azure-Table/1.0", "Microsoft-HTTPAPI/2.0" ], "Transfer-Encoding": "chunked", "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "942fb3d5-f474-4ed2-bb00-72f820bcb966", - "x-ms-request-id": "544a162e-1002-0020-55b5-bce126000000", + "x-ms-client-request-id": "4a1d558b-9bfa-421d-a07a-b0f296b9f746", + "x-ms-request-id": "7cf6a812-8002-0032-491d-c29af6000000", "x-ms-version": "2019-02-02" }, "ResponseBody": { "odata.metadata": "https://fakeaccountname.table.core.windows.net/$metadata#tableClientTestnode", "value": [ { - "odata.etag": "W/\u0022datetime\u00272022-08-30T21%3A15%3A33.9474727Z\u0027\u0022", + "odata.etag": "W/\u0022datetime\u00272022-09-06T18%3A24%3A19.0162561Z\u0027\u0022", "PartitionKey": "p1", "RowKey": "r1", - "Timestamp": "2022-08-30T21:15:33.9474727Z", + "Timestamp": "2022-09-06T18:24:19.0162561Z", "date@odata.type": "Edm.DateTime", "date": "2019-07-10T18:59:59.999Z" } ] } - }, - { - "RequestUri": "https://fakeaccountname.table.core.windows.net/Tables(\u0027tableClientTestnode\u0027)?st=2021-08-03T08:52:15Z\u0026spr=https\u0026sig=fakesigval", - "RequestMethod": "DELETE", - "RequestHeaders": { - "Accept": "application/json", - "Accept-Encoding": "gzip,deflate", - "User-Agent": "azsdk-js-data-tables/13.1.2 core-rest-pipeline/1.9.2 Node/v16.14.2 OS/(x64-Linux-5.4.0-1086-azure)", - "x-ms-client-request-id": "bf99db6e-5fae-4513-92b6-d8f4f71fab3e", - "x-ms-version": "2019-02-02" - }, - "RequestBody": null, - "StatusCode": 204, - "ResponseHeaders": { - "Cache-Control": "no-cache", - "Content-Length": "0", - "Date": "Tue, 30 Aug 2022 21:15:33 GMT", - "Server": [ - "Windows-Azure-Table/1.0", - "Microsoft-HTTPAPI/2.0" - ], - "X-Content-Type-Options": "nosniff", - "x-ms-client-request-id": "bf99db6e-5fae-4513-92b6-d8f4f71fab3e", - "x-ms-request-id": "544a162f-1002-0020-56b5-bce126000000", - "x-ms-version": "2019-02-02" - }, - "ResponseBody": null } ], "Variables": {} diff --git a/sdk/tables/data-tables/test/public/tableclient.spec.ts b/sdk/tables/data-tables/test/public/tableclient.spec.ts index 5f39c53de738..62209d9b79c9 100644 --- a/sdk/tables/data-tables/test/public/tableclient.spec.ts +++ b/sdk/tables/data-tables/test/public/tableclient.spec.ts @@ -194,51 +194,45 @@ describe(`TableClient`, () => { }); it("should filter dates correctly", async function () { - await client.createTable(); - const propertyName = "date"; const comparisonDate = new Date("2019-07-10T12:00:00-0700"); - try { - const entities = [ - { - partitionKey: "p1", - rowKey: "r1", - [propertyName]: new Date(comparisonDate.valueOf() - 1), - }, - { - partitionKey: "p1", - rowKey: "r2", - [propertyName]: comparisonDate, - }, - { - partitionKey: "p1", - rowKey: "r3", - [propertyName]: new Date(comparisonDate.valueOf() + 1), - }, - ]; - - for (const entity of entities) { - await client.createEntity(entity); - } + const entities = [ + { + partitionKey: "p1", + rowKey: "r1", + [propertyName]: new Date(comparisonDate.valueOf() - 1), + }, + { + partitionKey: "p1", + rowKey: "r2", + [propertyName]: comparisonDate, + }, + { + partitionKey: "p1", + rowKey: "r3", + [propertyName]: new Date(comparisonDate.valueOf() + 1), + }, + ]; - const entityIterable = client.listEntities({ - queryOptions: { - filter: odata`${propertyName} lt ${comparisonDate}`, - }, - }); + for (const entity of entities) { + await client.createEntity(entity); + } - const responseDates = []; - for await (const entity of entityIterable) { - assert.property(entity, propertyName); - assert.typeOf(entity[propertyName], "Date"); - responseDates.push(entity[propertyName] as Date); - } + const entityIterable = client.listEntities({ + queryOptions: { + filter: odata`${propertyName} lt ${comparisonDate}`, + }, + }); - assert.deepEqual(new Set(responseDates), new Set([entities[0][propertyName]])); - } finally { - await client.deleteTable(); + const responseDates = []; + for await (const entity of entityIterable) { + assert.property(entity, propertyName); + assert.typeOf(entity[propertyName], "Date"); + responseDates.push(entity[propertyName] as Date); } + + assert.deepEqual(new Set(responseDates), new Set([entities[0][propertyName]])); }); });