Skip to content

Commit 750ba15

Browse files
authored
fix(amplify-codegen): iOS use default when PK.OptionallyManagedId (#469)
1 parent 463fef4 commit 750ba15

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

packages/appsync-modelgen-plugin/src/__tests__/visitors/__snapshots__/appsync-swift-visitor.test.ts.snap

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,8 @@ extension ModelExplicitDefaultPk {
417417
}
418418
419419
extension ModelExplicitDefaultPk: ModelIdentifiable {
420-
public typealias IdentifierFormat = ModelIdentifierFormat.Custom
421-
public typealias IdentifierProtocol = ModelIdentifier<Self, ModelIdentifierFormat.Custom>
422-
}
423-
424-
extension ModelExplicitDefaultPk.IdentifierProtocol {
425-
public static func identifier(id: String) -> Self {
426-
.make(fields:[(name: \\"id\\", value: id)])
427-
}
420+
public typealias IdentifierFormat = ModelIdentifierFormat.Default
421+
public typealias IdentifierProtocol = DefaultModelIdentifier<Self>
428422
}"
429423
`;
430424

packages/appsync-modelgen-plugin/src/visitors/appsync-swift-visitor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ export class AppSyncSwiftVisitor<
320320
let result: string[] = [];
321321
const primaryKeyField = model.fields.find(field => field.primaryKeyInfo)!;
322322
const { primaryKeyType, sortKeyFields } = primaryKeyField.primaryKeyInfo!;
323-
const useDefaultExplicitID = primaryKeyType === CodeGenPrimaryKeyType.ManagedId;
323+
const useDefaultExplicitID =
324+
primaryKeyType === CodeGenPrimaryKeyType.ManagedId || primaryKeyType === CodeGenPrimaryKeyType.OptionallyManagedId;
324325

325326
const identifiableExtension = new SwiftDeclarationBlock()
326327
.asKind('extension')

0 commit comments

Comments
 (0)