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
2 changes: 1 addition & 1 deletion .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: Image ${{ matrix.image }}
strategy:
matrix:
image: ["swift:6.1.0-noble", "swift:6.1.0-jammy", "swift:6.0.0-noble"]
image: ["swift:6.1.2-noble", "swift:6.1.2-jammy", "swift:6.0.3-noble"]
runs-on: ubuntu-latest
container:
image: ${{ matrix.image }}
Expand Down
64 changes: 41 additions & 23 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// This source file is part of the DynamoDBTables open source project
//
// This file is forked from
// This file is forked from
// https://github.com/amzn/smoke-dynamodb/Package.swift.
// Copyright 2018-2022 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// Licensed under Apache License v2.0
Expand All @@ -29,8 +29,11 @@ let swiftSettings: [SwiftSetting] = []
let package = Package(
name: "dynamo-db-tables",
platforms: [
.macOS(.v10_15), .iOS(.v13), .watchOS(.v6), .tvOS(.v13)
],
.macOS(.v12),
.iOS(.v13),
.tvOS(.v13),
.watchOS(.v6),
],
products: [
.library(
name: "DynamoDBTables",
Expand All @@ -39,8 +42,8 @@ let package = Package(
dependencies: [
.package(url: "https://github.com/awslabs/aws-sdk-swift.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0"..<"3.0.0"),
.package(url: "https://github.com/JohnSundell/CollectionConcurrencyKit", from :"0.2.0"),
.package(url: "https://github.com/apple/swift-metrics.git", "1.0.0" ..< "3.0.0"),
.package(url: "https://github.com/JohnSundell/CollectionConcurrencyKit", from: "0.2.0"),
.package(url: "https://github.com/nicklockwood/SwiftFormat", from: "0.53.9"),
.package(url: "https://github.com/apple/swift-syntax", from: "601.0.0"),
],
Expand All @@ -64,5 +67,4 @@ let package = Package(
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
],
swiftSettings: swiftSettings),
]
)
])
Original file line number Diff line number Diff line change
Expand Up @@ -98,39 +98,34 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {
}

func polymorphicQuery<ReturnedType: PolymorphicOperationReturnType>(forPartitionKey partitionKey: String,
sortKeyCondition: AttributeCondition?,
consistentRead: Bool) async throws
sortKeyCondition: AttributeCondition?) async throws
-> [ReturnedType]
{
try await self.polymorphicPartialQuery(forPartitionKey: partitionKey,
sortKeyCondition: sortKeyCondition,
exclusiveStartKey: nil,
consistentRead: consistentRead)
exclusiveStartKey: nil)
}

// function to return a future with the results of a query call and all future paginated calls
private func polymorphicPartialQuery<ReturnedType: PolymorphicOperationReturnType>(
forPartitionKey partitionKey: String,
sortKeyCondition: AttributeCondition?,
exclusiveStartKey: String?,
consistentRead: Bool) async throws -> [ReturnedType]
exclusiveStartKey: String?) async throws -> [ReturnedType]
{
let paginatedItems: ([ReturnedType], String?) =
try await polymorphicQuery(forPartitionKey: partitionKey,
sortKeyCondition: sortKeyCondition,
limit: nil,
scanIndexForward: true,
exclusiveStartKey: exclusiveStartKey,
consistentRead: consistentRead)
exclusiveStartKey: exclusiveStartKey)

// if there are more items
if let lastEvaluatedKey = paginatedItems.1 {
// returns a future with all the results from all later paginated calls
let partialResult: [ReturnedType] = try await self.polymorphicPartialQuery(
forPartitionKey: partitionKey,
sortKeyCondition: sortKeyCondition,
exclusiveStartKey: lastEvaluatedKey,
consistentRead: consistentRead)
exclusiveStartKey: lastEvaluatedKey)

// return the results from 'this' call and all later paginated calls
return paginatedItems.0 + partialResult
Expand All @@ -143,32 +138,29 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {
func polymorphicQuery<ReturnedType: PolymorphicOperationReturnType>(forPartitionKey partitionKey: String,
sortKeyCondition: AttributeCondition?,
limit: Int?,
exclusiveStartKey: String?,
consistentRead: Bool) async throws
exclusiveStartKey: String?) async throws
-> (items: [ReturnedType], lastEvaluatedKey: String?)
{
try await self.polymorphicQuery(forPartitionKey: partitionKey,
sortKeyCondition: sortKeyCondition,
limit: limit,
scanIndexForward: true,
exclusiveStartKey: exclusiveStartKey,
consistentRead: consistentRead)
exclusiveStartKey: exclusiveStartKey)
}

func polymorphicQuery<ReturnedType: PolymorphicOperationReturnType>(forPartitionKey partitionKey: String,
sortKeyCondition: AttributeCondition?,
limit: Int?,
scanIndexForward: Bool,
exclusiveStartKey: String?,
consistentRead: Bool) async throws
exclusiveStartKey: String?) async throws
-> (items: [ReturnedType], lastEvaluatedKey: String?)
{
let queryInput = try AWSDynamoDB.QueryInput.forSortKeyCondition(partitionKey: partitionKey, targetTableName: targetTableName,
primaryKeyType: ReturnedType.AttributesType.self,
sortKeyCondition: sortKeyCondition, limit: limit,
scanIndexForward: scanIndexForward,
exclusiveStartKey: exclusiveStartKey,
consistentRead: consistentRead)
consistentRead: self.tableConfiguration.consistentRead)

let logMessage = "dynamodb.query with partitionKey: \(partitionKey), " +
"sortKeyCondition: \(sortKeyCondition.debugDescription), and table name \(targetTableName)."
Expand Down Expand Up @@ -232,39 +224,34 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {
}

func query<AttributesType, ItemType, TimeToLiveAttributesType>(forPartitionKey partitionKey: String,
sortKeyCondition: AttributeCondition?,
consistentRead: Bool) async throws
sortKeyCondition: AttributeCondition?) async throws
-> [TypedTTLDatabaseItem<AttributesType, ItemType, TimeToLiveAttributesType>]
{
try await self.partialQuery(forPartitionKey: partitionKey,
sortKeyCondition: sortKeyCondition,
exclusiveStartKey: nil,
consistentRead: consistentRead)
exclusiveStartKey: nil)
}

// function to return a future with the results of a query call and all future paginated calls
private func partialQuery<AttributesType, ItemType, TimeToLiveAttributesType>(
forPartitionKey partitionKey: String,
sortKeyCondition: AttributeCondition?,
exclusiveStartKey _: String?,
consistentRead: Bool) async throws -> [TypedTTLDatabaseItem<AttributesType, ItemType, TimeToLiveAttributesType>]
exclusiveStartKey _: String?) async throws -> [TypedTTLDatabaseItem<AttributesType, ItemType, TimeToLiveAttributesType>]
{
let paginatedItems: ([TypedTTLDatabaseItem<AttributesType, ItemType, TimeToLiveAttributesType>], String?) =
try await query(forPartitionKey: partitionKey,
sortKeyCondition: sortKeyCondition,
limit: nil,
scanIndexForward: true,
exclusiveStartKey: nil,
consistentRead: consistentRead)
exclusiveStartKey: nil)

// if there are more items
if let lastEvaluatedKey = paginatedItems.1 {
// returns a future with all the results from all later paginated calls
let partialResult: [TypedTTLDatabaseItem<AttributesType, ItemType, TimeToLiveAttributesType>] = try await self.partialQuery(
forPartitionKey: partitionKey,
sortKeyCondition: sortKeyCondition,
exclusiveStartKey: lastEvaluatedKey,
consistentRead: consistentRead)
exclusiveStartKey: lastEvaluatedKey)

// return the results from 'this' call and all later paginated calls
return paginatedItems.0 + partialResult
Expand All @@ -278,16 +265,15 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {
sortKeyCondition: AttributeCondition?,
limit: Int?,
scanIndexForward: Bool,
exclusiveStartKey: String?,
consistentRead: Bool) async throws
exclusiveStartKey: String?) async throws
-> (items: [TypedTTLDatabaseItem<AttributesType, ItemType, TimeToLiveAttributesType>], lastEvaluatedKey: String?)
{
let queryInput = try AWSDynamoDB.QueryInput.forSortKeyCondition(
partitionKey: partitionKey, targetTableName: targetTableName,
primaryKeyType: AttributesType.self,
sortKeyCondition: sortKeyCondition, limit: limit,
scanIndexForward: scanIndexForward, exclusiveStartKey: exclusiveStartKey,
consistentRead: consistentRead)
consistentRead: self.tableConfiguration.consistentRead)

let logMessage = "dynamodb.query with partitionKey: \(partitionKey), " +
"sortKeyCondition: \(sortKeyCondition.debugDescription), and table name \(targetTableName)."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
//===----------------------------------------------------------------------===//

//
// DynamoDBCompositePrimaryKeyTable+bulkUpdateSupport.swift
// AWSDynamoDBCompositePrimaryKeyTable+bulkUpdateSupport.swift
// DynamoDBTables
//

Expand Down Expand Up @@ -60,7 +60,7 @@ func getAttributes(forItem item: TypedTTLDatabaseItem<some Any, some Any, some A
return attributes
}

extension DynamoDBCompositePrimaryKeyTable {
extension AWSDynamoDBCompositePrimaryKeyTable {
func getUpdateExpression<AttributesType, ItemType, TimeToLiveAttributesType>(
tableName: String,
newItem: TypedTTLDatabaseItem<AttributesType, ItemType, TimeToLiveAttributesType>,
Expand Down Expand Up @@ -309,7 +309,7 @@ extension DynamoDBCompositePrimaryKeyTable {
/// does not know where the string should end. Therefore, need to escape
/// single quote by doubling it. E.g. 'foo'bar' becomes 'foo''bar'.
private func sanitizeString(_ string: String) -> String {
if self.escapeSingleQuoteInPartiQL {
if self.tableConfiguration.escapeSingleQuoteInPartiQL {
return string.replacingOccurrences(of: "'", with: "''")
} else {
return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {
let statement = try getDeleteExpression(tableName: self.targetTableName,
existingKey: existingKey)

return DynamoDBClientTypes.BatchStatementRequest(consistentRead: true, statement: statement)
return DynamoDBClientTypes.BatchStatementRequest(consistentRead: self.tableConfiguration.consistentRead, statement: statement)
}

let executeInput = BatchExecuteStatementInput(statements: statements)
Expand All @@ -64,7 +64,7 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {
let statement = try getDeleteExpression(tableName: self.targetTableName,
existingItem: existingItem)

return DynamoDBClientTypes.BatchStatementRequest(consistentRead: true, statement: statement)
return DynamoDBClientTypes.BatchStatementRequest(consistentRead: self.tableConfiguration.consistentRead, statement: statement)
}

let executeInput = BatchExecuteStatementInput(statements: statements)
Expand Down
Loading
Loading