Skip to content

Commit

Permalink
Avoid conformances to external types. (#43)
Browse files Browse the repository at this point in the history
Update tools version to 6.0 and avoid conformances to external types.
  • Loading branch information
tachyonics authored Sep 18, 2024
1 parent 6329f26 commit 416a7e8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 24 deletions.
8 changes: 3 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.9
// swift-tools-version:6.0

//===----------------------------------------------------------------------===//
//
Expand All @@ -24,8 +24,7 @@
import CompilerPluginSupport
import PackageDescription

let swiftSettings: [SwiftSetting] = [.enableExperimentalFeature("StrictConcurrency=complete"),
]
let swiftSettings: [SwiftSetting] = []

let package = Package(
name: "dynamo-db-tables",
Expand Down Expand Up @@ -65,6 +64,5 @@ let package = Package(
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
],
swiftSettings: swiftSettings),
],
swiftLanguageVersions: [.v5]
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,11 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {

var errorCodeSet: Set<DynamoDBClientTypes.BatchStatementErrorCodeEnum> = Set()
// TODO: Remove errorCodeSet and return errorSet instead
var errorSet: Set<DynamoDBClientTypes.BatchStatementError> = Set()
var errorSet: Set<InternalBatchStatementError> = Set()
result.responses?.forEach { response in
if let error = response.error, let code = error.code {
errorCodeSet.insert(code)
errorSet.insert(error)
errorSet.insert(.init(code: error.code, item: error.item, message: error.message))
}
}

Expand Down Expand Up @@ -588,17 +588,13 @@ public extension AWSDynamoDBCompositePrimaryKeyTable {
}
}

extension DynamoDBClientTypes.BatchStatementError: Equatable {
public static func == (lhs: DynamoDBClientTypes.BatchStatementError, rhs: DynamoDBClientTypes.BatchStatementError) -> Bool {
guard lhs.code == rhs.code, lhs.item == rhs.item, lhs.message == rhs.message else {
return false
}

return true
}
struct InternalBatchStatementError: Equatable {
var code: DynamoDBClientTypes.BatchStatementErrorCodeEnum?
var item: [Swift.String: DynamoDBClientTypes.AttributeValue]?
var message: Swift.String?
}

extension DynamoDBClientTypes.BatchStatementError: Hashable {
extension InternalBatchStatementError: Hashable {
public func hash(into hasher: inout Hasher) {
hasher.combine(self.code)
hasher.combine(self.message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import SwiftSyntax
import SwiftSyntaxMacros

struct PolymorphicTransactionConstraintEntryMacroAttributes: MacroAttributes {
static var macroName: String = "PolymorphicTransactionConstraintEntry"
static let macroName: String = "PolymorphicTransactionConstraintEntry"

static var protocolName: String = "PolymorphicTransactionConstraintEntry"
static let protocolName: String = "PolymorphicTransactionConstraintEntry"

static var transformType: String = "WriteTransactionConstraintType"
static let transformType: String = "WriteTransactionConstraintType"

static var contextType: String = "PolymorphicWriteEntryContext"
static let contextType: String = "PolymorphicWriteEntryContext"
}

public enum PolymorphicTransactionConstraintEntryMacro: ExtensionMacro {
Expand Down
8 changes: 4 additions & 4 deletions Sources/DynamoDBTablesMacros/PolymorphicWriteEntryMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import SwiftSyntax
import SwiftSyntaxMacros

struct PolymorphicWriteEntryMacroAttributes: MacroAttributes {
static var macroName: String = "PolymorphicWriteEntry"
static let macroName: String = "PolymorphicWriteEntry"

static var protocolName: String = "PolymorphicWriteEntry"
static let protocolName: String = "PolymorphicWriteEntry"

static var transformType: String = "WriteEntryTransformType"
static let transformType: String = "WriteEntryTransformType"

static var contextType: String = "PolymorphicWriteEntryContext"
static let contextType: String = "PolymorphicWriteEntryContext"
}

public enum PolymorphicWriteEntryMacro: ExtensionMacro {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,13 +380,21 @@ struct InMemoryDynamoDBCompositePrimaryKeyTableTests {
#expect(retrievedItem1 != nil)

try await table.deleteItem(existingItem: databaseItem)

// suspend for a small interval so that the creation time of the recreated item is different
try await Task.sleep(for: .milliseconds(10))

let recreatedItem = StandardTypedDatabaseItem.newItem(withKey: key, andValue: payload)
_ = try await table.insertItem(recreatedItem)

do {
try await table.deleteItem(existingItem: databaseItem)

Issue.record("Expected error was not thrown")
} catch DynamoDBTableError.conditionalCheckFailed {
// expected error
} catch {
Issue.record("Expected error was not thrown")
}

let retrievedItem2: StandardTypedDatabaseItem<TestTypeA>? = try await table.getItem(forKey: key)
Expand Down

0 comments on commit 416a7e8

Please sign in to comment.