-
Notifications
You must be signed in to change notification settings - Fork 874
Features/dynamo db update behavior attribute #4049
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
base: development
Are you sure you want to change the base?
Changes from 2 commits
b7ac55a
ecb51e7
0f1d2d6
9daad45
fbe671e
4a9d4ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "services": [ | ||
| { | ||
| "serviceName": "DynamoDBv2", | ||
| "type": "minor", | ||
| "changeLogMessages": [ | ||
| "Add support for DynamoDbUpdateBehavior for operations." | ||
| ] | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
| /* | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"). | ||
| * You may not use this file except in compliance with the License. | ||
| * A copy of the License is located at | ||
| * | ||
| * http://aws.amazon.com/apache2.0 | ||
| * | ||
| * or in the "license" file accompanying this file. This file is distributed | ||
| * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
| * express or implied. See the License for the specific language governing | ||
| * permissions and limitations under the License. | ||
| */ | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
@@ -375,31 +375,35 @@ public IMultiTableTransactWrite CreateMultiTableTransactWrite(params ITransactWr | |
|
|
||
| Document updateDocument; | ||
| Expression versionExpression = null; | ||
|
||
|
|
||
| var returnValues=counterConditionExpression == null ? ReturnValues.None : ReturnValues.AllNewAttributes; | ||
|
|
||
| if ((flatConfig.SkipVersionCheck.HasValue && flatConfig.SkipVersionCheck.Value) || !storage.Config.HasVersion) | ||
| var updateIfNotExistsAttributeName = GetUpdateIfNotExistsAttributeNames(storage); | ||
|
|
||
| var returnValues = counterConditionExpression == null && !updateIfNotExistsAttributeName.Any() | ||
| ? ReturnValues.None | ||
| : ReturnValues.AllNewAttributes; | ||
irina-herciu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| var updateItemOperationConfig = new UpdateItemOperationConfig | ||
| { | ||
| updateDocument = table.UpdateHelper(storage.Document, table.MakeKey(storage.Document), new UpdateItemOperationConfig() | ||
| { | ||
| ReturnValues = returnValues | ||
| }, counterConditionExpression); | ||
| } | ||
| else | ||
| ReturnValues = returnValues | ||
| }; | ||
|
|
||
| if (!(flatConfig.SkipVersionCheck.HasValue && flatConfig.SkipVersionCheck.Value) && storage.Config.HasVersion) | ||
| { | ||
| var conversionConfig = new DynamoDBEntry.AttributeConversionConfig(table.Conversion, table.IsEmptyStringValueEnabled); | ||
| var conversionConfig = new DynamoDBEntry.AttributeConversionConfig(table.Conversion, table.IsEmptyStringValueEnabled); | ||
| versionExpression = CreateConditionExpressionForVersion(storage, conversionConfig); | ||
| SetNewVersion(storage); | ||
|
|
||
| var updateItemOperationConfig = new UpdateItemOperationConfig | ||
| { | ||
| ReturnValues = returnValues, | ||
| ConditionalExpression = versionExpression, | ||
| }; | ||
| updateDocument = table.UpdateHelper(storage.Document, table.MakeKey(storage.Document), updateItemOperationConfig, counterConditionExpression); | ||
| updateItemOperationConfig.ConditionalExpression = versionExpression; | ||
| } | ||
|
|
||
| if (counterConditionExpression == null && versionExpression == null) return; | ||
| updateDocument = table.UpdateHelper( | ||
| storage.Document, | ||
| table.MakeKey(storage.Document), | ||
| updateItemOperationConfig, | ||
| counterConditionExpression, | ||
| updateIfNotExistsAttributeName | ||
| ); | ||
|
|
||
| if (counterConditionExpression == null && versionExpression == null && !updateIfNotExistsAttributeName.Any()) return; | ||
|
|
||
| if (returnValues == ReturnValues.AllNewAttributes) | ||
| { | ||
|
|
@@ -428,36 +432,36 @@ private async Task SaveHelperAsync([DynamicallyAccessedMembers(InternalConstants | |
| Document updateDocument; | ||
| Expression versionExpression = null; | ||
|
|
||
| var returnValues = counterConditionExpression == null ? ReturnValues.None : ReturnValues.AllNewAttributes; | ||
| var updateIfNotExistsAttributeName = GetUpdateIfNotExistsAttributeNames(storage); | ||
|
|
||
| var returnValues = counterConditionExpression == null && !updateIfNotExistsAttributeName.Any() | ||
| ? ReturnValues.None | ||
| : ReturnValues.AllNewAttributes; | ||
|
|
||
| if ( | ||
| (flatConfig.SkipVersionCheck.HasValue && flatConfig.SkipVersionCheck.Value) | ||
| || !storage.Config.HasVersion) | ||
| var updateItemOperationConfig = new UpdateItemOperationConfig | ||
| { | ||
| updateDocument = await table.UpdateHelperAsync(storage.Document, table.MakeKey(storage.Document), new UpdateItemOperationConfig | ||
| { | ||
| ReturnValues = returnValues | ||
| }, counterConditionExpression, cancellationToken).ConfigureAwait(false); | ||
| } | ||
| else | ||
| ReturnValues = returnValues | ||
| }; | ||
|
|
||
| if (!(flatConfig.SkipVersionCheck.HasValue && flatConfig.SkipVersionCheck.Value) && storage.Config.HasVersion) | ||
| { | ||
| var conversionConfig = new DynamoDBEntry.AttributeConversionConfig(table.Conversion, table.IsEmptyStringValueEnabled); | ||
| var conversionConfig = new DynamoDBEntry.AttributeConversionConfig(table.Conversion, table.IsEmptyStringValueEnabled); | ||
| versionExpression = CreateConditionExpressionForVersion(storage, conversionConfig); | ||
| SetNewVersion(storage); | ||
|
|
||
| updateDocument = await table.UpdateHelperAsync( | ||
| storage.Document, | ||
| table.MakeKey(storage.Document), | ||
| new UpdateItemOperationConfig | ||
| { | ||
| ReturnValues = returnValues, | ||
| ConditionalExpression = versionExpression | ||
| }, counterConditionExpression, | ||
| cancellationToken) | ||
| .ConfigureAwait(false); | ||
| updateItemOperationConfig.ConditionalExpression = versionExpression; | ||
| } | ||
|
|
||
| if (counterConditionExpression == null && versionExpression == null && !storage.Config.HasAutogeneratedProperties) return; | ||
| updateDocument = await table.UpdateHelperAsync( | ||
| storage.Document, | ||
| table.MakeKey(storage.Document), | ||
| updateItemOperationConfig, | ||
| counterConditionExpression, | ||
| cancellationToken, | ||
| updateIfNotExistsAttributeName | ||
| ).ConfigureAwait(false); | ||
|
|
||
|
|
||
| if (counterConditionExpression == null && versionExpression == null && !updateIfNotExistsAttributeName.Any()) return; | ||
|
|
||
| if (returnValues == ReturnValues.AllNewAttributes) | ||
| { | ||
|
|
@@ -698,4 +702,4 @@ private async Task SaveHelperAsync([DynamicallyAccessedMembers(InternalConstants | |
|
|
||
| #endregion | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.