Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed issue with multiple params in a filter #15893

Merged
merged 8 commits into from
Jan 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
19 changes: 19 additions & 0 deletions sdk/tables/azure-data-tables/azure/data/tables/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,25 @@ def _batch_send( # pylint: disable=inconsistent-return-statements
)
return transaction_result

def _parameter_filter_substitution( # pylint: disable = R0201
self,
parameters, # type: dict[str,str]
filter # type: str # pylint: disable = W0622
):
"""Replace user defined parameter in filter
:param parameters: User defined parameters
:param filter: Filter for querying
"""
if parameters:
filter_strings = filter.split(' ')
for idx, f in enumerate(filter_strings):
if '@' in f:
val = parameters[f[1:]]
filter_strings[idx] = "'{}'".format(val)
return ' '.join(filter_strings)

return filter # pylint: disable = W0622


class TransportWrapper(HttpTransport):
"""Wrapper class that ensures that an inner client created
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,23 +82,5 @@ def _validate_signed_identifiers(cls, signed_identifiers):
"""
if len(signed_identifiers) > 5:
raise ValueError(
"Too many access policies provided. The server does not support setting "
"more than 5 access policies on a single resource."
)

def _parameter_filter_substitution( # pylint: disable = R0201
self,
parameters, # type: dict[str,str]
filter, # type: str # pylint: disable = W0622
):
"""Replace user defined parameter in filter
:param parameters: User defined parameters
:param filter: Filter for querying
"""
if parameters:
filter_start = filter.split("@")[0]
selected = filter.split("@")[1]
for key, value in parameters.items():
if key == selected:
filter = filter_start.replace("@", value) # pylint: disable = W0622
return filter # pylint: disable = W0622
'Too many access policies provided. The server does not support setting '
'more than 5 access policies on a single resource.')
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,3 @@ def _format_url(self, hostname):
mode hostname.
"""
return "{}://{}{}".format(self.scheme, hostname, self._query_str)

def _parameter_filter_substitution( # pylint: disable = R0201
self,
parameters, # type: dict[str,str]
filter, # type: str # pylint: disable = W0622
):
"""Replace user defined parameter in filter
:param parameters: User defined parameters
:param filter: Filter for querying
"""
if parameters:
filter_start = filter.split("@")[0]
selected = filter.split("@")[1]
for key, value in parameters.items():
if key == selected:
filter = filter_start.replace("@", value) # pylint: disable = W0622
return filter # pylint: disable = W0622
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ interactions:
DataServiceVersion:
- '3.0'
Date:
- Fri, 18 Dec 2020 17:09:42 GMT
- Mon, 04 Jan 2021 20:31:14 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Fri, 18 Dec 2020 17:09:42 GMT
- Mon, 04 Jan 2021 20:31:14 GMT
x-ms-version:
- '2019-02-02'
method: POST
Expand All @@ -33,7 +33,7 @@ interactions:
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Fri, 18 Dec 2020 17:09:42 GMT
- Mon, 04 Jan 2021 20:31:14 GMT
location:
- https://fake_table_account.table.core.windows.net/Tables('uttable546210aa')
server:
Expand Down Expand Up @@ -69,27 +69,27 @@ interactions:
DataServiceVersion:
- '3.0'
Date:
- Fri, 18 Dec 2020 17:09:43 GMT
- Mon, 04 Jan 2021 20:31:14 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Fri, 18 Dec 2020 17:09:43 GMT
- Mon, 04 Jan 2021 20:31:14 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://fake_table_account.table.core.windows.net/uttable546210aa
response:
body:
string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable546210aa/@Element","odata.etag":"W/\"datetime''2020-12-18T17%3A09%3A43.740726Z''\"","PartitionKey":"pk546210aa","RowKey":"rk546210aa","Timestamp":"2020-12-18T17:09:43.740726Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}'
string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable546210aa/@Element","odata.etag":"W/\"datetime''2021-01-04T20%3A31%3A15.1344959Z''\"","PartitionKey":"pk546210aa","RowKey":"rk546210aa","Timestamp":"2021-01-04T20:31:15.1344959Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}'
headers:
cache-control:
- no-cache
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Fri, 18 Dec 2020 17:09:42 GMT
- Mon, 04 Jan 2021 20:31:14 GMT
etag:
- W/"datetime'2020-12-18T17%3A09%3A43.740726Z'"
- W/"datetime'2021-01-04T20%3A31%3A15.1344959Z'"
location:
- https://fake_table_account.table.core.windows.net/uttable546210aa(PartitionKey='pk546210aa',RowKey='rk546210aa')
server:
Expand All @@ -103,6 +103,48 @@ interactions:
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, 04 Jan 2021 20:31:15 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 04 Jan 2021 20:31:15 GMT
x-ms-version:
- '2019-02-02'
method: GET
uri: https://fake_table_account.table.core.windows.net/uttable546210aa()?$filter=married%20eq%20%27True%27
response:
body:
string: '{"odata.metadata":"https://fake_table_account.table.core.windows.net/$metadata#uttable546210aa","value":[]}'
headers:
cache-control:
- no-cache
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Mon, 04 Jan 2021 20:31:15 GMT
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:
Expand All @@ -115,11 +157,11 @@ interactions:
Content-Length:
- '0'
Date:
- Fri, 18 Dec 2020 17:09:43 GMT
- Mon, 04 Jan 2021 20:31:15 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Fri, 18 Dec 2020 17:09:43 GMT
- Mon, 04 Jan 2021 20:31:15 GMT
x-ms-version:
- '2019-02-02'
method: DELETE
Expand All @@ -133,7 +175,7 @@ interactions:
content-length:
- '0'
date:
- Fri, 18 Dec 2020 17:09:43 GMT
- Mon, 04 Jan 2021 20:31:15 GMT
server:
- Windows-Azure-Table/1.0 Microsoft-HTTPAPI/2.0
x-content-type-options:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
interactions:
- request:
body: '{"TableName": "uttable97e31758"}'
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, 21 Dec 2020 20:57:18 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 21 Dec 2020 20:57:18 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://tablesteststorname.table.core.windows.net/Tables
response:
body:
string: '{"odata.metadata":"https://tablesteststorname.table.core.windows.net/$metadata#Tables/@Element","TableName":"uttable97e31758"}'
headers:
cache-control:
- no-cache
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Mon, 21 Dec 2020 20:57:18 GMT
location:
- https://tablesteststorname.table.core.windows.net/Tables('uttable97e31758')
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": "pk97e31758", "PartitionKey@odata.type": "Edm.String",
"RowKey": "rk97e31758", "RowKey@odata.type": "Edm.String", "age": 39, "sex":
"male", "sex@odata.type": "Edm.String", "married": true, "deceased": false,
"ratio": 3.1, "evenratio": 3.0, "large": 933311100, "Birthday": "1973-10-04T00:00:00Z",
"Birthday@odata.type": "Edm.DateTime", "birthday": "1970-10-04T00:00:00Z", "birthday@odata.type":
"Edm.DateTime", "binary": "YmluYXJ5", "binary@odata.type": "Edm.Binary", "other":
20, "clsid": "c9da6455-213d-42c9-9a79-3e9149a57833", "clsid@odata.type": "Edm.Guid"}'
headers:
Accept:
- application/json;odata=minimalmetadata
Accept-Encoding:
- gzip, deflate
Connection:
- keep-alive
Content-Length:
- '577'
Content-Type:
- application/json;odata=nometadata
DataServiceVersion:
- '3.0'
Date:
- Mon, 21 Dec 2020 20:57:18 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 21 Dec 2020 20:57:18 GMT
x-ms-version:
- '2019-02-02'
method: POST
uri: https://tablesteststorname.table.core.windows.net/uttable97e31758
response:
body:
string: '{"odata.metadata":"https://tablesteststorname.table.core.windows.net/$metadata#uttable97e31758/@Element","odata.etag":"W/\"datetime''2020-12-21T20%3A57%3A18.8679026Z''\"","PartitionKey":"pk97e31758","RowKey":"rk97e31758","Timestamp":"2020-12-21T20:57:18.8679026Z","age":39,"sex":"male","married":true,"deceased":false,"ratio":3.1,"evenratio":3.0,"large":933311100,"Birthday@odata.type":"Edm.DateTime","Birthday":"1973-10-04T00:00:00Z","birthday@odata.type":"Edm.DateTime","birthday":"1970-10-04T00:00:00Z","binary@odata.type":"Edm.Binary","binary":"YmluYXJ5","other":20,"clsid@odata.type":"Edm.Guid","clsid":"c9da6455-213d-42c9-9a79-3e9149a57833"}'
headers:
cache-control:
- no-cache
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Mon, 21 Dec 2020 20:57:18 GMT
etag:
- W/"datetime'2020-12-21T20%3A57%3A18.8679026Z'"
location:
- https://tablesteststorname.table.core.windows.net/uttable97e31758(PartitionKey='pk97e31758',RowKey='rk97e31758')
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, 21 Dec 2020 20:57:18 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 21 Dec 2020 20:57:18 GMT
x-ms-version:
- '2019-02-02'
method: GET
uri: https://tablesteststorname.table.core.windows.net/uttable97e31758()?$filter=married%20eq%20%27True%27%20and%20RowKey%20eq%20%27rk97e31758%27
response:
body:
string: '{"odata.metadata":"https://tablesteststorname.table.core.windows.net/$metadata#uttable97e31758","value":[]}'
headers:
cache-control:
- no-cache
content-type:
- application/json;odata=minimalmetadata;streaming=true;charset=utf-8
date:
- Mon, 21 Dec 2020 20:57:18 GMT
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, 21 Dec 2020 20:57:18 GMT
User-Agent:
- azsdk-python-data-tables/12.0.0b4 Python/3.9.0rc1 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Mon, 21 Dec 2020 20:57:18 GMT
x-ms-version:
- '2019-02-02'
method: DELETE
uri: https://tablesteststorname.table.core.windows.net/Tables('uttable97e31758')
response:
body:
string: ''
headers:
cache-control:
- no-cache
content-length:
- '0'
date:
- Mon, 21 Dec 2020 20:57:19 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