Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
11 changes: 11 additions & 0 deletions generator/.DevConfigs/fde42955-138d-44dc-8373-e98e836b33e3.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"services": [
{
"serviceName": "DynamoDBv2",
"type": "patch",
"changeLogMessages": [
"Add missing `SkipVersionCheck` property to the `TransactWriteConfig` class (https://github.com/aws/aws-sdk-net/issues/4243)"
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ private void CheckUseVersioning()
if (_config.SkipVersionCheck == true)
{
throw new InvalidOperationException(
"Using DynamoDBContextConfig.SkipVersionCheck property with true value is not supported for this operation.");
"Using the SkipVersionCheck property with true value is not supported for this operation.");
}

if (!_storageConfig.HasVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ public class TransactWriteConfig : BaseOperationConfig
/// </summary>
public bool? IgnoreNullValues { get; set; }

/// <summary>
/// Property that directs <see cref="DynamoDBContext"/> to skip version checks
/// when saving or deleting an object with a version attribute.
/// If property is not set, version checks are performed.
/// </summary>
public bool? SkipVersionCheck { get; set; }

/// <inheritdoc/>
internal override DynamoDBOperationConfig ToDynamoDBOperationConfig()
{
var config = base.ToDynamoDBOperationConfig();
config.IgnoreNullValues = IgnoreNullValues;
config.SkipVersionCheck = SkipVersionCheck;

return config;
}
Expand Down
43 changes: 43 additions & 0 deletions sdk/test/Services/DynamoDBv2/IntegrationTests/DataModelTests.cs
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Side note but this class is getting out of hand, there's almost 5k lines... Before the test refactoring is done, I'll see if I can clean up this a little bit (for example, by moving the DynamoDBTable classes to their own files).

Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,49 @@ private async Task TestCompositeHashRangeTable()
Assert.AreEqual(0, gsi4PriorityResults.Count);
}

/// <summary>
/// Tests regression reported in https://github.com/aws/aws-sdk-net/issues/4243 is resolved.
/// </summary>
[TestMethod]
[TestCategory("DynamoDBv2")]
public async Task TestTransactWrite_SkipVersionCheck()
{
TableCache.Clear();
await CleanupTables();
TableCache.Clear();

CreateContext(DynamoDBEntryConversion.V2, true, true);

var vp = new VersionedProduct
{
Id = 1000,
Name = "TestProduct",
Price = 100
};
await Context.SaveAsync(vp);

// Load to get initial version
vp = await Context.LoadAsync<VersionedProduct>(vp.Id);
Assert.AreEqual(0, vp.Version);

// Set wrong version - normally would fail with a ConditionalCheck error
vp.Version = 9999;
vp.Price = 200;

// With SkipVersionCheck = true, should succeed
var transactWrite = Context.CreateTransactWrite<VersionedProduct>(new TransactWriteConfig
{
SkipVersionCheck = true
});
transactWrite.AddSaveItem(vp);
await transactWrite.ExecuteAsync();

// Verify update succeeded
var updated = await Context.LoadAsync<VersionedProduct>(vp.Id);
Assert.AreEqual(200, updated.Price);
Assert.AreEqual(9999, updated.Version);
}

[TestMethod]
[TestCategory("DynamoDBv2")]
public async Task TestContextWithEmptyStringDisabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void TransactWriteConfig()
{
// If this fails because you've added a property, be sure to add it to
// `ToDynamoDBOperationConfig` before updating this unit test
Assert.AreEqual(5, typeof(TransactWriteConfig).GetProperties().Length);
Assert.AreEqual(6, typeof(TransactWriteConfig).GetProperties().Length);
}

[TestMethod]
Expand Down
Loading