Skip to content

Commit e01751d

Browse files
authored
fix(delegate): remove createMany from delegate input types (#1619)
1 parent d0fd350 commit e01751d

File tree

1 file changed

+7
-4
lines changed
  • packages/schema/src/plugins/enhancer/enhance

1 file changed

+7
-4
lines changed

packages/schema/src/plugins/enhancer/enhance/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,12 +486,12 @@ export function enhance(prisma: any, context?: EnhancementContext<${authTypePara
486486
const typeName = typeAlias.getName();
487487
const delegateModelNames = delegateModels.map(([delegate]) => delegate.name);
488488
const delegateCreateUpdateInputRegex = new RegExp(
489-
`\\${delegateModelNames.join('|')}(Unchecked)?(Create|Update).*Input`
489+
`^(${delegateModelNames.join('|')})(Unchecked)?(Create|Update).*Input$`
490490
);
491491
if (delegateCreateUpdateInputRegex.test(typeName)) {
492492
const toRemove = typeAlias
493493
.getDescendantsOfKind(SyntaxKind.PropertySignature)
494-
.filter((p) => ['create', 'connectOrCreate', 'upsert'].includes(p.getName()));
494+
.filter((p) => ['create', 'createMany', 'connectOrCreate', 'upsert'].includes(p.getName()));
495495
toRemove.forEach((r) => {
496496
source = source.replace(r.getText(), '');
497497
});
@@ -543,6 +543,10 @@ export function enhance(prisma: any, context?: EnhancementContext<${authTypePara
543543
return source;
544544
}
545545

546+
private readonly CreateUpdateWithoutDelegateRelationRegex = new RegExp(
547+
`(.+)(Create|Update)Without${upperCaseFirst(DELEGATE_AUX_RELATION_PREFIX)}_(.+)Input`
548+
);
549+
546550
private removeDelegateFieldsFromNestedMutationInput(
547551
typeAlias: TypeAliasDeclaration,
548552
_delegateInfo: DelegateInfo,
@@ -553,8 +557,7 @@ export function enhance(prisma: any, context?: EnhancementContext<${authTypePara
553557
// remove delegate model fields (and corresponding fk fields) from
554558
// create/update input types nested inside concrete models
555559

556-
const regex = new RegExp(`(.+)(Create|Update)Without${upperCaseFirst(DELEGATE_AUX_RELATION_PREFIX)}_(.+)Input`);
557-
const match = name.match(regex);
560+
const match = name.match(this.CreateUpdateWithoutDelegateRelationRegex);
558561
if (!match) {
559562
return source;
560563
}

0 commit comments

Comments
 (0)