Skip to content

Commit

Permalink
Update dependencies (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
inputfalken authored May 27, 2024
1 parent 632cace commit 4324723
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 40 deletions.
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public class ProductRepository
_queryByPrice = Product.QueryByPrice
.OnTable(tableName)
.WithKeyConditionExpression((db, arg) => $"{db.Price} = {arg}")
.ToQueryRequestBuilder()
.ToQueryRequestBuilder()
with
{
IndexName = Product.PriceIndex
};
{
IndexName = Product.PriceIndex
};
}

public async Task<IReadOnlyList<Product>> SearchByPrice(decimal price)
Expand Down Expand Up @@ -119,16 +119,15 @@ public class ProductRepository
}

// These attributes is what makes the source generator kick in. Make sure to have the class 'partial' as well.
[DynamoDBMarshaller(typeof(Product), PropertyName = "Put")]
[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof(string), PropertyName = "GetById")]
[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof((string Id, decimal NewPrice, DateTime TimeStamp)), PropertyName = "UpdatePrice")]
[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof(decimal), PropertyName = "QueryByPrice")]
[DynamoDBMarshaller(AccessName = "Put")]
[DynamoDBMarshaller(AccessName = "GetById", ArgumentType = typeof(string))]
[DynamoDBMarshaller(AccessName = "UpdatePrice", ArgumentType = typeof((string Id, decimal NewPrice, DateTime TimeStamp)))]
[DynamoDBMarshaller(AccessName = "QueryByPrice", ArgumentType = typeof(decimal))]
public partial record Product(
[property: DynamoDBHashKey, DynamoDBGlobalSecondaryIndexRangeKey(Product.PriceIndex)] string Id,
[property: DynamoDBGlobalSecondaryIndexHashKey(Product.PriceIndex)] decimal Price,
string Description,
Product.MetadataEntity Metadata
)
Product.MetadataEntity Metadata)
{
public const string PriceIndex = "PriceIndex";

Expand Down
19 changes: 9 additions & 10 deletions samples/Repository/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public ProductRepository(string tableName, IAmazonDynamoDB amazonDynamoDb)
_queryByPrice = Product.QueryByPrice
.OnTable(tableName)
.WithKeyConditionExpression((db, arg) => $"{db.Price} = {arg}")
.ToQueryRequestBuilder()
.ToQueryRequestBuilder()
with
{
IndexName = Product.PriceIndex
};
{
IndexName = Product.PriceIndex
};
}

public async Task<IReadOnlyList<Product>> SearchByPrice(decimal price)
Expand Down Expand Up @@ -98,16 +98,15 @@ public async Task Create(Product product)
}

// These attributes is what makes the source generator kick in. Make sure to have the class 'partial' as well.
[DynamoDBMarshaller(typeof(Product), PropertyName = "Put")]
[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof(string), PropertyName = "GetById")]
[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof((string Id, decimal NewPrice, DateTime TimeStamp)), PropertyName = "UpdatePrice")]
[DynamoDBMarshaller(typeof(Product), ArgumentType = typeof(decimal), PropertyName = "QueryByPrice")]
[DynamoDBMarshaller(AccessName = "Put")]
[DynamoDBMarshaller(AccessName = "GetById", ArgumentType = typeof(string))]
[DynamoDBMarshaller(AccessName = "UpdatePrice", ArgumentType = typeof((string Id, decimal NewPrice, DateTime TimeStamp)))]
[DynamoDBMarshaller(AccessName = "QueryByPrice", ArgumentType = typeof(decimal))]
public partial record Product(
[property: DynamoDBHashKey, DynamoDBGlobalSecondaryIndexRangeKey(Product.PriceIndex)] string Id,
[property: DynamoDBGlobalSecondaryIndexHashKey(Product.PriceIndex)] decimal Price,
string Description,
Product.MetadataEntity Metadata
)
Product.MetadataEntity Metadata)
{
public const string PriceIndex = "PriceIndex";

Expand Down
6 changes: 5 additions & 1 deletion src/Dynatello/Builders/QueryRequestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ internal QueryRequestBuilder(Func<T, IAttributeExpression> attributeExpressionSe
TableName = tableName;
}

/// <summary>
///
/// </summary>
[Obsolete(Constants.ObsoleteConstructorMessage, true)]
public QueryRequestBuilder()
{
Expand Down Expand Up @@ -80,6 +83,7 @@ public QueryRequest Build(T arg)

if (Limit is { } limit)
queryRequest.Limit = limit;
else

if (IndexName is not null)
queryRequest.IndexName = IndexName;
Expand All @@ -89,4 +93,4 @@ public QueryRequest Build(T arg)

return queryRequest;
}
}
}
4 changes: 2 additions & 2 deletions src/Dynatello/Dynatello.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DynamoDBGenerator" Version="0.7.5"/>
<PackageReference Include="DynamoDBGenerator.SourceGenerator" Version="0.7.5"/>
<PackageReference Include="DynamoDBGenerator" Version="0.8.1"/>
<PackageReference Include="DynamoDBGenerator.SourceGenerator" Version="0.8.1"/>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions tests/Dynatello.Tests/ToPutItemRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Dynatello.Tests;

[DynamoDBMarshaller(typeof(User))]
[DynamoDBMarshaller(EntityType = typeof(User))]
public partial class ToPutItemRequestTests
{
private readonly Fixture _fixture = new();
Expand Down Expand Up @@ -139,4 +139,4 @@ public class UpdateUserEmail
public string UserId { get; set; } = null!;
public string UserEmail { get; set; } = null!;
public DateTimeOffset TimeStamp { get; set; }
}
}
20 changes: 8 additions & 12 deletions tests/Dynatello.Tests/ToQueryRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,18 @@ public void Build_Request_FilterExpression()
}
}

[DynamoDBMarshaller(typeof(Cat), PropertyName = "QueryWithCuteness",
ArgumentType = typeof((Guid Id, double MinimumCuteness)))]
[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByCompositeKey", ArgumentType = typeof((Guid Id, Guid HomeId)))]
[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetById", ArgumentType = typeof(Guid))]
[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByInvalidPartition", ArgumentType = typeof(string))]
[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByCompositeInvalidPartition",
ArgumentType = typeof((string Id, Guid HomeId)))]
[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByCompositeInvalidRange",
ArgumentType = typeof((Guid Id, string HomeId)))]
[DynamoDBMarshaller(typeof(Cat), PropertyName = "GetByCompositeInvalidPartitionAndRange",
ArgumentType = typeof((double Id, string HomeId)))]
[DynamoDBMarshaller(AccessName = "QueryWithCuteness", ArgumentType = typeof((Guid Id, double MinimumCuteness)))]
[DynamoDBMarshaller(AccessName = "GetByCompositeKey", ArgumentType = typeof((Guid Id, Guid HomeId)))]
[DynamoDBMarshaller(AccessName = "GetById", ArgumentType = typeof(Guid))]
[DynamoDBMarshaller(AccessName = "GetByInvalidPartition", ArgumentType = typeof(string))]
[DynamoDBMarshaller(AccessName = "GetByCompositeInvalidPartition", ArgumentType = typeof((string Id, Guid HomeId)))]
[DynamoDBMarshaller(AccessName = "GetByCompositeInvalidRange", ArgumentType = typeof((Guid Id, string HomeId)))]
[DynamoDBMarshaller(AccessName = "GetByCompositeInvalidPartitionAndRange", ArgumentType = typeof((double Id, string HomeId)))]
public readonly partial record struct Cat(
[property: DynamoDBHashKey] Guid Id,
[property: DynamoDBRangeKey] Guid HomeId,
string Name,
double Cuteness)
{
public static readonly Fixture Fixture = new();
}
}
6 changes: 3 additions & 3 deletions tests/Dynatello.Tests/ToUpdateItemRequestTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

namespace Dynatello.Tests;

[DynamoDBMarshaller(typeof(User))]
[DynamoDBMarshaller(typeof(User), PropertyName = "UpdateEmail", ArgumentType = typeof(UpdateUserEmail))]
[DynamoDBMarshaller(EntityType = typeof(User))]
[DynamoDBMarshaller(EntityType = typeof(User), AccessName = "UpdateEmail", ArgumentType = typeof(UpdateUserEmail))]
public partial class ToUpdateItemRequestTests
{
private readonly Fixture _fixture = new();
Expand Down Expand Up @@ -210,4 +210,4 @@ static void Expected(User x, UpdateRequestBuilder<User> builder) =>
UpdateExpression = "SET #Email = :p1, #Firstname = :p2"
});
}
}
}

0 comments on commit 4324723

Please sign in to comment.