Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Goa.Clients.Dynamo.Enums;

/// <summary>
/// Specifies how to return attribute values when a condition check fails.
/// </summary>
public enum ReturnValuesOnConditionCheckFailure
{
/// <summary>
/// Nothing is returned. (This is the default.)
/// </summary>
NONE,

/// <summary>
/// Returns all attributes of the item as they appeared before the operation.
/// </summary>
ALL_OLD
}
18 changes: 18 additions & 0 deletions src/Clients/Goa.Clients.Dynamo/Models/ItemCollectionMetrics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
namespace Goa.Clients.Dynamo.Models;

/// <summary>
/// Information about item collections, if any, that were affected by the operation.
/// </summary>
public class ItemCollectionMetrics
{
/// <summary>
/// The partition key value of the item collection.
/// </summary>
public Dictionary<string, AttributeValue>? ItemCollectionKey { get; set; }

/// <summary>
/// An estimate of item collection size, in gigabytes. This value is a two-element array
/// containing a lower bound and an upper bound for the estimate.
/// </summary>
public List<double>? SizeEstimateRangeGB { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@ public class BatchWriteItemResponse
/// The write capacity units consumed by the BatchWriteItem operation.
/// </summary>
public List<ConsumedCapacity>? ConsumedCapacity { get; set; }

/// <summary>
/// A list of tables that were processed by BatchWriteItem and, for each table, information about any item collections that were affected by individual DeleteItem or PutItem operations.
/// </summary>
public Dictionary<string, List<ItemCollectionMetrics>>? ItemCollectionMetrics { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,38 @@ public DeleteItemBuilder WithKey(string attributeName, AttributeValue value)

/// <summary>
/// Sets a condition expression that must be satisfied for the delete operation to succeed.
/// Multiple conditions are combined with AND.
/// </summary>
/// <param name="condition">The condition that must be met.</param>
/// <returns>The DeleteItemBuilder instance for method chaining.</returns>
public DeleteItemBuilder WithCondition(Condition condition)
{
if (string.IsNullOrEmpty(condition.Expression))
{
return this;
}

if (string.IsNullOrEmpty(_request.ConditionExpression))
{
_request.ConditionExpression = condition.Expression;
}
else
{
_request.ConditionExpression += " AND " + condition.Expression;
_request.ConditionExpression = $"({_request.ConditionExpression}) AND ({condition.Expression})";
}

if (condition.ExpressionNames.Count > 0)
{
_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
}

if (condition.ExpressionValues.Count > 0)
{
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
}

_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
return this;
}

Expand Down Expand Up @@ -90,6 +104,17 @@ public DeleteItemBuilder WithReturnItemCollectionMetrics(ReturnItemCollectionMet
return this;
}

/// <summary>
/// Specifies how to return attribute values when a conditional check fails.
/// </summary>
/// <param name="returnValuesOnConditionCheckFailure">The return values on condition check failure setting.</param>
/// <returns>The DeleteItemBuilder instance for method chaining.</returns>
public DeleteItemBuilder WithReturnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure returnValuesOnConditionCheckFailure)
{
_request.ReturnValuesOnConditionCheckFailure = returnValuesOnConditionCheckFailure;
return this;
}

/// <summary>
/// Builds and returns the configured DeleteItemRequest.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,10 @@ public class DeleteItemRequest
/// Determines whether item collection metrics are returned.
/// </summary>
public ReturnItemCollectionMetrics ReturnItemCollectionMetrics { get; set; } = ReturnItemCollectionMetrics.NONE;

/// <summary>
/// Specifies how to return attribute values when a conditional check fails.
/// Use ALL_OLD to return all attributes of the item as they appeared before the operation.
/// </summary>
public ReturnValuesOnConditionCheckFailure ReturnValuesOnConditionCheckFailure { get; set; } = ReturnValuesOnConditionCheckFailure.NONE;
Comment on lines +52 to +56
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

git ls-files | grep -E "(Delete|Dynamo)" | head -20

Repository: Im5tu/goa

Length of output: 1599


🏁 Script executed:

find . -name "*DeleteItem*" -o -name "*ReturnValuesOnConditionCheckFailure*" | head -20

Repository: Im5tu/goa

Length of output: 493


🏁 Script executed:

fd -t f "DeleteItemRequest" | head -10

Repository: Im5tu/goa

Length of output: 126


🏁 Script executed:

fd -t f "ReturnValuesOnConditionCheckFailure" | head -10

Repository: Im5tu/goa

Length of output: 128


🏁 Script executed:

cat -n src/Clients/Goa.Clients.Dynamo/Enums/ReturnValuesOnConditionCheckFailure.cs

Repository: Im5tu/goa

Length of output: 595


🏁 Script executed:

cat -n src/Clients/Goa.Clients.Dynamo/Operations/DeleteItem/DeleteItemRequest.cs

Repository: Im5tu/goa

Length of output: 2759


🏁 Script executed:

cat -n src/Clients/Goa.Clients.Dynamo/Operations/DeleteItem/DeleteItemBuilder.cs

Repository: Im5tu/goa

Length of output: 5725


🏁 Script executed:

cat -n src/Clients/Goa.Clients.Dynamo/Operations/DeleteItem/DeleteItemResponse.cs

Repository: Im5tu/goa

Length of output: 1002


🏁 Script executed:

find . -path "*/DeleteItem*" -name "*.cs" | xargs ls -la

Repository: Im5tu/goa

Length of output: 428


🏁 Script executed:

find . -name "*Serializer*" -o -name "*WireModel*" -o -name "*Wire*" | grep -i dynamo

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

fd -t f "DeleteItem" --exec grep -l "ReturnValuesOnConditionCheckFailure" {} \;

Repository: Im5tu/goa

Length of output: 283


🏁 Script executed:

fd -t f "Test" | grep -i deleteitem

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

git ls-files | grep -i test | head -20

Repository: Im5tu/goa

Length of output: 1737


🏁 Script executed:

find . -name "*.Tests.cs" -o -name "*Tests" -type d | head -10

Repository: Im5tu/goa

Length of output: 379


🏁 Script executed:

rg "ReturnValuesOnConditionCheckFailure" --type cs

Repository: Im5tu/goa

Length of output: 2823


🏁 Script executed:

cat -n src/Clients/Goa.Clients.Dynamo/Operations/Transactions/TransactDeleteItem.cs

Repository: Im5tu/goa

Length of output: 1827


🏁 Script executed:

find . -path "*/DeleteItem*" -o -name "*Serializer*" | xargs rg -l "DeleteItem" 2>/dev/null | head -10

Repository: Im5tu/goa

Length of output: 510


🏁 Script executed:

fd -t f "Dynamo.*Test" tests/Clients/Goa.Clients.Dynamo.Tests/

Repository: Im5tu/goa

Length of output: 254


🏁 Script executed:

ls -la tests/Clients/Goa.Clients.Dynamo.Tests/

Repository: Im5tu/goa

Length of output: 630


🏁 Script executed:

find tests/Clients/Goa.Clients.Dynamo.Tests -name "*.cs" | grep -i delete

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

rg "DeleteItem" tests/Clients/Goa.Clients.Dynamo.Tests/ -C 3

Repository: Im5tu/goa

Length of output: 10190


🏁 Script executed:

rg "ReturnValuesOnConditionCheckFailure" tests/ -C 2

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

cat -n tests/Clients/Goa.Clients.Dynamo.Tests/DynamoClientIntegrationTests.cs | head -100

Repository: Im5tu/goa

Length of output: 3900


🏁 Script executed:

find . -name "*.cs" -path "*/Dynamo/*" | xargs rg -l "ToJson|Serialize|Wire" | head -5

Repository: Im5tu/goa

Length of output: 315


🏁 Script executed:

find . -name "*.cs" -path "*/Dynamo/*" | xargs rg -l "JsonSerializableAttribute|JsonConverter|JsonPropertyName" | head -10

Repository: Im5tu/goa

Length of output: 785


🏁 Script executed:

find . -name "*Client*.cs" -path "*/Dynamo/*" | head -10

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

fd -t f "DynamoClient" | grep -v Test | head -5

Repository: Im5tu/goa

Length of output: 100


🏁 Script executed:

cat -n $(fd -t f "DynamoClient" | grep -v Test | head -1)

Repository: Im5tu/goa

Length of output: 6315


🏁 Script executed:

find . -name "DynamoClient.cs" -o -name "*DynamoClient*.cs" | grep -v Test | grep -v Interface

Repository: Im5tu/goa

Length of output: 102


🏁 Script executed:

rg "class DynamoClient" src/Clients/Goa.Clients.Dynamo/

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

find src/Clients/Goa.Clients.Dynamo -name "*.cs" -type f | xargs grep -l "DeleteItemRequest" | grep -v Operations | head -5

Repository: Im5tu/goa

Length of output: 220


🏁 Script executed:

cat -n src/Clients/Goa.Clients.Dynamo/DynamoServiceClient.cs | head -150

Repository: Im5tu/goa

Length of output: 7640


🏁 Script executed:

cat -n src/Clients/Goa.Clients.Dynamo/Serialization/DynamoJsonContext.cs

Repository: Im5tu/goa

Length of output: 3678


🏁 Script executed:

rg "ReturnValuesOnConditionCheckFailure" src/Clients/Goa.Clients.Dynamo/Serialization/

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

rg "UseStringEnumConverter\|JsonConverter\|ReturnValuesOnConditionCheckFailure" src/Clients/Goa.Clients.Dynamo/Serialization/ -A 2 -B 2

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

grep -n "ReturnValuesOnConditionCheckFailure" src/Clients/Goa.Clients.Dynamo/Serialization/DynamoJsonContext.cs

Repository: Im5tu/goa

Length of output: 35


🏁 Script executed:

find . -name "*.cs" -path "*/Serialization/*" -o -name "*Converter*.cs" | xargs grep -l "ReturnValuesOnConditionCheckFailure" 2>/dev/null

Repository: Im5tu/goa

Length of output: 37


🌐 Web query:

AWS DynamoDB DeleteItem API ReturnValuesOnConditionCheckFailure parameter valid values enum

💡 Result:

Valid values: ALL_OLD and NONE. [1][2]

Sources:

  • AWS DeleteItem API reference (ReturnValuesOnConditionCheckFailure). [1]
  • AWS SDK Java enum ReturnValuesOnConditionCheckFailure (ALL_OLD, NONE). [2]

🏁 Script executed:

cat -n src/Clients/Goa.Clients.Dynamo/Serialization/DynamoJsonContext.cs | grep -E "JsonSerializable.*Delete|JsonSerializable.*Return"

Repository: Im5tu/goa

Length of output: 431


🏁 Script executed:

rg "class DeleteItemRequest" src/Clients/Goa.Clients.Dynamo/Operations/DeleteItem/DeleteItemRequest.cs -A 10 | head -20

Repository: Im5tu/goa

Length of output: 463


🏁 Script executed:

find . -name "*.cs" -path "*/Serialization/*" | xargs cat | grep -i "returnvalues"

Repository: Im5tu/goa

Length of output: 93


🏁 Script executed:

python3 << 'EOF'
# Check if ReturnValuesOnConditionCheckFailure would be serialized as part of DeleteItemRequest
# when UseStringEnumConverter is set globally

import json

# The question is: does the enum get serialized when it's a property of a JsonSerializable class?
# With UseStringEnumConverter = true globally, nested enums should serialize as strings

# Looking at the context:
# - DeleteItemRequest is [JsonSerializable] (line 32)
# - UseStringEnumConverter = true (line 22)
# - ReturnValuesOnConditionCheckFailure is a property of DeleteItemRequest
# - The enum is NOT explicitly in [JsonSerializable] attributes

# This means the enum MIGHT serialize correctly due to global setting, but it's not explicit

print("ANALYSIS:")
print("1. DeleteItemRequest IS in [JsonSerializable] list (line 32)")
print("2. UseStringEnumConverter = true is set globally (line 22)")
print("3. ReturnValuesOnConditionCheckFailure property is part of DeleteItemRequest")
print("")
print("POTENTIAL ISSUE:")
print("- The enum is NOT explicitly listed in [JsonSerializable] attributes")
print("- While global UseStringEnumConverter may handle it, best practice is explicit")
print("- Missing from serialization context like other enums (ReturnValues, ReturnConsumedCapacity, etc.)")
EOF

Repository: Im5tu/goa

Length of output: 139


🏁 Script executed:

# Let's verify AWS parameter field name
web_search_query="AWS DynamoDB DeleteItem API request parameter field name ReturnValuesOnConditionCheckFailure JSON"
echo "Searching for field name mapping in AWS docs..."

Repository: Im5tu/goa

Length of output: 100


🏁 Script executed:

rg "WithReturnValuesOnConditionCheckFailure\|ReturnValuesOnConditionCheckFailure\s*=" tests/ -C 2

Repository: Im5tu/goa

Length of output: 35


Add ReturnValuesOnConditionCheckFailure to the serialization context and add test coverage.

While the enum values (NONE, ALL_OLD) correctly match AWS DynamoDB's DeleteItem API contract and the property is properly integrated into the request/builder, two issues need addressing:

  1. The enum should be explicitly registered in DynamoJsonContext as [JsonSerializable(typeof(ReturnValuesOnConditionCheckFailure))] (lines 19-62) for consistency with similar enums like ReturnValues, ReturnConsumedCapacity, and ReturnItemCollectionMetrics, even though the global UseStringEnumConverter setting may handle it implicitly.

  2. Add a test case for WithReturnValuesOnConditionCheckFailure() to verify the property is correctly serialized and sent to DynamoDB, similar to existing builder tests.

🤖 Prompt for AI Agents
In `@src/Clients/Goa.Clients.Dynamo/Operations/DeleteItem/DeleteItemRequest.cs`
around lines 52 - 56, DynamoJsonContext is missing an explicit JsonSerializable
registration for the enum ReturnValuesOnConditionCheckFailure and there is no
test ensuring WithReturnValuesOnConditionCheckFailure() gets serialized; add
[JsonSerializable(typeof(ReturnValuesOnConditionCheckFailure))] to the
DynamoJsonContext attribute list (alongside ReturnValues,
ReturnConsumedCapacity, ReturnItemCollectionMetrics) so the enum is explicitly
wired into the source-generated JSON context, then add a unit test that uses the
DeleteItem request builder (call
WithReturnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure.ALL_OLD)
or NONE) and asserts the produced serialized request includes the correct
ReturnValuesOnConditionCheckFailure value sent to DynamoDB (mirroring existing
builder tests for ReturnValues).

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ public class DeleteItemResponse
/// The number of capacity units consumed by the operation.
/// </summary>
public double? ConsumedCapacityUnits { get; set; }

/// <summary>
/// Information about item collections, if any, that were affected by the operation.
/// </summary>
public Dictionary<string, List<ItemCollectionMetrics>>? ItemCollectionMetrics { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,38 @@ public PutItemBuilder WithAttribute(string attributeName, AttributeValue value)

/// <summary>
/// Sets a condition expression that must be satisfied for the put operation to succeed.
/// Multiple conditions are combined with AND.
/// </summary>
/// <param name="condition">The condition that must be met.</param>
/// <returns>The PutItemBuilder instance for method chaining.</returns>
public PutItemBuilder WithCondition(Condition condition)
{
_request.ConditionExpression = condition.Expression;
_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
if (string.IsNullOrEmpty(condition.Expression))
{
return this;
}

if (string.IsNullOrEmpty(_request.ConditionExpression))
{
_request.ConditionExpression = condition.Expression;
}
else
{
_request.ConditionExpression = $"({_request.ConditionExpression}) AND ({condition.Expression})";
}

if (condition.ExpressionNames.Count > 0)
{
_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
}

if (condition.ExpressionValues.Count > 0)
{
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
}

return this;
}

Expand All @@ -76,6 +98,17 @@ public PutItemBuilder WithReturnValues(ReturnValues returnValues)
return this;
}

/// <summary>
/// Specifies how to return attribute values when a conditional check fails.
/// </summary>
/// <param name="returnValuesOnConditionCheckFailure">The return values on condition check failure setting.</param>
/// <returns>The PutItemBuilder instance for method chaining.</returns>
public PutItemBuilder WithReturnValuesOnConditionCheckFailure(ReturnValuesOnConditionCheckFailure returnValuesOnConditionCheckFailure)
{
_request.ReturnValuesOnConditionCheckFailure = returnValuesOnConditionCheckFailure;
return this;
}

/// <summary>
/// Builds and returns the configured PutItemRequest.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,10 @@ public class PutItemRequest
/// Determines whether item collection metrics are returned.
/// </summary>
public ReturnItemCollectionMetrics ReturnItemCollectionMetrics { get; set; } = ReturnItemCollectionMetrics.NONE;

/// <summary>
/// Specifies how to return attribute values when a conditional check fails.
/// Use ALL_OLD to return all attributes of the item as they appeared before the operation.
/// </summary>
public ReturnValuesOnConditionCheckFailure ReturnValuesOnConditionCheckFailure { get; set; } = ReturnValuesOnConditionCheckFailure.NONE;
}
64 changes: 53 additions & 11 deletions src/Clients/Goa.Clients.Dynamo/Operations/Query/QueryBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Text.RegularExpressions;
using Goa.Clients.Dynamo.Enums;
using Goa.Clients.Dynamo.Models;
using Goa.Core;
Expand All @@ -8,7 +9,7 @@ namespace Goa.Clients.Dynamo.Operations.Query;
/// Fluent builder for constructing DynamoDB Query requests with a user-friendly API.
/// </summary>
/// <param name="tableName">The name of the table to query.</param>
public class QueryBuilder(string tableName)
public partial class QueryBuilder(string tableName)
{
private readonly QueryRequest _request = new()
{
Expand All @@ -31,10 +32,18 @@ public QueryBuilder WithKey(Condition condition)
_request.KeyConditionExpression += " AND " + condition.Expression;
}

_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
if (condition.ExpressionNames.Count > 0)
{
_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
}

if (condition.ExpressionValues.Count > 0)
{
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
}

return this;
}

Expand All @@ -54,20 +63,45 @@ public QueryBuilder WithConsistentRead(bool consistentRead = true)
/// </summary>
/// <param name="indexName">The name of the index to query, or null to query the base table.</param>
/// <returns>The QueryBuilder instance for method chaining.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown when indexName length is less than 3 or greater than 255 characters.</exception>
/// <exception cref="ArgumentException">Thrown when indexName contains invalid characters (must match pattern [a-zA-Z0-9_.-]+).</exception>
public QueryBuilder WithIndex(string? indexName)
{
_request.IndexName = string.IsNullOrWhiteSpace(indexName) ? null : indexName;
if (string.IsNullOrWhiteSpace(indexName))
{
_request.IndexName = null;
return this;
}

ArgumentOutOfRangeException.ThrowIfLessThan(indexName.Length, 3, nameof(indexName));
ArgumentOutOfRangeException.ThrowIfGreaterThan(indexName.Length, 255, nameof(indexName));

if (!IndexNamePattern().IsMatch(indexName))
{
throw new ArgumentException("Index name must match pattern [a-zA-Z0-9_.-]+.", nameof(indexName));
}

_request.IndexName = indexName;
return this;
}

[GeneratedRegex("^[a-zA-Z0-9_.-]+$")]
private static partial Regex IndexNamePattern();

/// <summary>
/// Sets the maximum number of items to return from the query.
/// </summary>
/// <param name="limit">The maximum number of items to return, or null for no limit.</param>
/// <returns>The QueryBuilder instance for method chaining.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown when limit is less than 1.</exception>
public QueryBuilder WithLimit(int? limit)
{
_request.Limit = limit > 0 ? limit : null;
if (limit.HasValue)
{
ArgumentOutOfRangeException.ThrowIfLessThan(limit.Value, 1, nameof(limit));
}

_request.Limit = limit;
return this;
}

Expand Down Expand Up @@ -175,10 +209,18 @@ public QueryBuilder WithFilter(Condition condition)
_request.FilterExpression += " AND " + condition.Expression;
}

_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
if (condition.ExpressionNames.Count > 0)
{
_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
}

if (condition.ExpressionValues.Count > 0)
{
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
}

return this;
}

Expand Down
16 changes: 12 additions & 4 deletions src/Clients/Goa.Clients.Dynamo/Operations/Scan/ScanBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,18 @@ public ScanBuilder WithFilter(Condition condition)
_request.FilterExpression += " AND " + condition.Expression;
}

_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
if (condition.ExpressionNames.Count > 0)
{
_request.ExpressionAttributeNames ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeNames.Merge(condition.ExpressionNames);
}

if (condition.ExpressionValues.Count > 0)
{
_request.ExpressionAttributeValues ??= new(StringComparer.OrdinalIgnoreCase);
_request.ExpressionAttributeValues.Merge(condition.ExpressionValues);
}

return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Goa.Clients.Dynamo.Models;
using Goa.Clients.Dynamo.Enums;
using Goa.Clients.Dynamo.Models;

namespace Goa.Clients.Dynamo.Operations.Transactions;

Expand Down Expand Up @@ -31,4 +32,10 @@ public class TransactConditionCheckItem
/// One or more substitution tokens for attribute names in an expression.
/// </summary>
public Dictionary<string, string>? ExpressionAttributeNames { get; set; }

/// <summary>
/// Specifies how to return attribute values when a conditional check fails.
/// Use ALL_OLD to return all attributes of the item as they appeared before the operation.
/// </summary>
public ReturnValuesOnConditionCheckFailure ReturnValuesOnConditionCheckFailure { get; set; } = ReturnValuesOnConditionCheckFailure.NONE;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Goa.Clients.Dynamo.Models;
using Goa.Clients.Dynamo.Enums;
using Goa.Clients.Dynamo.Models;

namespace Goa.Clients.Dynamo.Operations.Transactions;

Expand Down Expand Up @@ -31,4 +32,10 @@ public class TransactDeleteItem
/// One or more substitution tokens for attribute names in an expression.
/// </summary>
public Dictionary<string, string>? ExpressionAttributeNames { get; set; }

/// <summary>
/// Specifies how to return attribute values when a conditional check fails.
/// Use ALL_OLD to return all attributes of the item as they appeared before the operation.
/// </summary>
public ReturnValuesOnConditionCheckFailure ReturnValuesOnConditionCheckFailure { get; set; } = ReturnValuesOnConditionCheckFailure.NONE;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Goa.Clients.Dynamo.Enums;
using Goa.Clients.Dynamo.Models;

namespace Goa.Clients.Dynamo.Operations.Transactions;
Expand Down Expand Up @@ -70,6 +71,17 @@ public TransactGetBuilder WithGet(string tableName, Dictionary<string, Attribute
return WithGet(tableName, key);
}

/// <summary>
/// Determines the level of detail about consumed capacity to return.
/// </summary>
/// <param name="returnConsumedCapacity">The level of consumed capacity information to return.</param>
/// <returns>The TransactGetBuilder instance for method chaining.</returns>
public TransactGetBuilder WithReturnConsumedCapacity(ReturnConsumedCapacity returnConsumedCapacity)
{
_request.ReturnConsumedCapacity = returnConsumedCapacity;
return this;
}

/// <summary>
/// Builds and returns the configured TransactGetRequest.
/// </summary>
Expand Down
Loading
Loading