Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
weblate committed Jan 7, 2025
2 parents 1ee2a0d + 88dddf9 commit cfa1237
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
13 changes: 10 additions & 3 deletions internal/dynamo/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,20 @@ func (c *Client) One(ctx context.Context, pk PK, sk SK, v interface{}) error {

func (c *Client) OneByUID(ctx context.Context, uid string, v interface{}) error {
response, err := c.svc.Query(ctx, &dynamodb.QueryInput{
TableName: aws.String(c.table),
IndexName: aws.String(lpaUIDIndex),
ExpressionAttributeNames: map[string]string{"#LpaUID": "LpaUID"},
TableName: aws.String(c.table),
IndexName: aws.String(lpaUIDIndex),
ExpressionAttributeNames: map[string]string{
"#LpaUID": "LpaUID",
"#PK": "PK",
"#SK": "SK",
},
ExpressionAttributeValues: map[string]types.AttributeValue{
":LpaUID": &types.AttributeValueMemberS{Value: uid},
":PK": &types.AttributeValueMemberS{Value: LpaKey("").PK()},
":SK": &types.AttributeValueMemberS{Value: DonorKey("").SK()},
},
KeyConditionExpression: aws.String("#LpaUID = :LpaUID"),
FilterExpression: aws.String("begins_with(#PK, :PK) and begins_with(#SK, :SK)"),
Limit: aws.Int32(1),
})
if err != nil {
Expand Down
17 changes: 11 additions & 6 deletions internal/dynamo/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,17 @@ func TestOneByUID(t *testing.T) {
dynamoDB := newMockDynamoDB(t)
dynamoDB.EXPECT().
Query(ctx, &dynamodb.QueryInput{
TableName: aws.String("this"),
IndexName: aws.String(lpaUIDIndex),
ExpressionAttributeNames: map[string]string{"#LpaUID": "LpaUID"},
ExpressionAttributeValues: map[string]types.AttributeValue{":LpaUID": &types.AttributeValueMemberS{Value: "M-1111-2222-3333"}},
KeyConditionExpression: aws.String("#LpaUID = :LpaUID"),
Limit: aws.Int32(1),
TableName: aws.String("this"),
IndexName: aws.String(lpaUIDIndex),
ExpressionAttributeNames: map[string]string{"#LpaUID": "LpaUID", "#PK": "PK", "#SK": "SK"},
ExpressionAttributeValues: map[string]types.AttributeValue{
":LpaUID": &types.AttributeValueMemberS{Value: "M-1111-2222-3333"},
":PK": &types.AttributeValueMemberS{Value: LpaKey("").PK()},
":SK": &types.AttributeValueMemberS{Value: DonorKey("").SK()},
},
KeyConditionExpression: aws.String("#LpaUID = :LpaUID"),
FilterExpression: aws.String("begins_with(#PK, :PK) and begins_with(#SK, :SK)"),
Limit: aws.Int32(1),
}).
Return(&dynamodb.QueryOutput{
Items: []map[string]types.AttributeValue{{
Expand Down

0 comments on commit cfa1237

Please sign in to comment.