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

filter option in query_entities for TableClient is being ignored (Python) #15094

Closed
alejolp opened this issue Nov 6, 2020 · 3 comments · Fixed by #15096
Closed

filter option in query_entities for TableClient is being ignored (Python) #15094

alejolp opened this issue Nov 6, 2020 · 3 comments · Fixed by #15096
Assignees
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Tables

Comments

@alejolp
Copy link

alejolp commented Nov 6, 2020

Hi, I'm using the Python Data Tables Python API and when filtering entities with query_entities for TableClient, all entities were returned. No filtering was applied. This code example should fail but it silently returns all the entities in the table:

from azure.data.tables import TableClient
client2 = TableClient.from_connection_string(conn_str=connection_string, table_name="Y")
for row in client2.query_entities("aaa bbb ccc"):
    print(row)

Enabling DEBUG level in logging shows the URL missing the $filter parameter:

INFO:azure.core.pipeline.policies.http_logging_policy:Request URL: 'https://x.table.core.windows.net/Y()'

Going through the source code, it seems that the filter option is being discarded when constructing the paging object in file sdk/tables/azure-data-tables/azure/data/tables/_models.py:

return self._command(
                query_options=self.results_per_page

I have to manually edit the _kwargs attribute of the returned ItemPaged value from the call to query_entities and set the key results_per_page to a QueryOptions instance. For example:

from azure.data.tables import TableClient

client3 = TableClient.from_connection_string(conn_str=connection_string, table_name="Y")
result = client3.query_entities('')
result._kwargs['results_per_page'] = QueryOptions(filter='aaa bbb ccc')

for row in result:
    print(row)

It properly fails with an Exception:

HttpResponseError: Syntax error at position 7 in 'aaa bbb ccc'.
@ghost ghost added needs-triage This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Nov 6, 2020
@annatisch annatisch added Client This issue points to a problem in the data-plane of the library. Tables labels Nov 7, 2020
@ghost ghost removed the needs-triage This is a new issue that needs to be triaged to the appropriate team. label Nov 7, 2020
@seankane-msft
Copy link
Member

@alejolp Thanks for the find and reporting the issue. I was able to reproduce this exact scenario with ease (thanks for the descriptiveness) and I have a PR that should address this in our next release which is planned to go out on Tuesday 11/10.

@seankane-msft seankane-msft self-assigned this Nov 7, 2020
@seankane-msft
Copy link
Member

@alejolp We decided to push this fix to the next release. We have a feeling this might affect the paging objects requiring additional clean ups. Apologies for the delay.

@annatisch
Copy link
Member

Change of plan - we've delayed the release until Thursday so we can get this fix in :)

openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-python that referenced this issue Jul 7, 2021
Updated examples to use non-global locations and added new flags (Azure#15094)

Co-authored-by: Avi Jerafi <avjerafi@microsoft.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Client This issue points to a problem in the data-plane of the library. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Tables
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants