Skip to content

[Tables] use etag from entity if match condition is given #18271

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

Merged
merged 7 commits into from
May 5, 2021

Conversation

seankane-msft
Copy link
Member

No description provided.

@seankane-msft seankane-msft self-assigned this Apr 23, 2021
@seankane-msft seankane-msft marked this pull request as draft April 23, 2021 19:25
@annatisch annatisch linked an issue May 5, 2021 that may be closed by this pull request
@seankane-msft seankane-msft marked this pull request as ready for review May 5, 2021 16:39
@seankane-msft seankane-msft requested a review from annatisch May 5, 2021 16:40
if match_condition and not etag:
try:
etag = entity.metadata.get("etag", None)
except AttributeError:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might also need to catch TypeError here - if a customer passes in a TableEntity instance they created, then entity.metadata will be None (and we should add a test for this).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated and added a test!

new_etag = e.metadata["etag"]
e.metadata["etag"] = old_etag

with pytest.raises(HttpResponseError):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually just a raw HttpResponseError? Or are we raising azure.core.ResourceModifiedError?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a raw HttpResponseError, here's what it looks like.

E           azure.core.exceptions.HttpResponseError: The update condition specified in the request was not satisfied.
E           RequestId:0c9fe685-8002-003d-4cd4-41ac3f000000
E           Time:2021-05-05T17:33:24.9865841Z
E           ErrorCode:UpdateConditionNotSatisfied

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting! I've made a note to fix that - but could come post-GA if needed.

@seankane-msft seankane-msft merged commit 8e20b81 into Azure:master May 5, 2021
@seankane-msft seankane-msft deleted the tables-match-etag branch May 5, 2021 18:43
iscai-msft added a commit to iscai-msft/azure-sdk-for-python that referenced this pull request May 5, 2021
…into azure_purview_catalog

* 'master' of https://github.com/Azure/azure-sdk-for-python:
  ignore analysis for swagger readmes (Azure#18520)
  [purview] add azure-purview-nspkg (Azure#18518)
  [AppConfiguration] Appconfig consistency (Azure#18493)
  [Container Registry] Improved samples (Azure#18263)
  [Container Registry] renamings (Azure#18492)
  [ServiceBus] internal code rename and sample readme update (Azure#18516)
  [EventHub] update link in sample readme (Azure#18517)
  Post Process Event Names Script (Azure#18419)
  [Tables] use etag from entity if match condition is given (Azure#18271)
  adding operation-location to headers that are scrubbed (Azure#18514)
iscai-msft added a commit to iscai-msft/azure-sdk-for-python that referenced this pull request May 6, 2021
…into azure_purview_scanning

* 'master' of https://github.com/Azure/azure-sdk-for-python: (550 commits)
  del useless files (Azure#18528)
  delete existing useless files for trafficmanager (Azure#18525)
  Define new replacer to replace keys in recording (Azure#18294)
  [purview] add purview nspkg to ci (Azure#18523)
  ignore analysis for swagger readmes (Azure#18520)
  [purview] add azure-purview-nspkg (Azure#18518)
  [AppConfiguration] Appconfig consistency (Azure#18493)
  [Container Registry] Improved samples (Azure#18263)
  [Container Registry] renamings (Azure#18492)
  [ServiceBus] internal code rename and sample readme update (Azure#18516)
  [EventHub] update link in sample readme (Azure#18517)
  Post Process Event Names Script (Azure#18419)
  [Tables] use etag from entity if match condition is given (Azure#18271)
  adding operation-location to headers that are scrubbed (Azure#18514)
  [Tables] Adds support for AzureNamedKeyCredential (Azure#18456)
  [Tables] delete_entity takes an entity instead of row and partition key (Azure#18269)
  [Tables] Removed TableEntity attribute wrapper (Azure#18489)
  [EventHub&ServiceBus] Bump uAMQP dependency (Azure#17942)
  [ServiceBus] add keyword override support to update_ methods in mgmt module (Azure#18210)
  Add compatibility switch to disable CAE (Azure#18148)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Tables] Use entity etag in match conditions
2 participants