Repository: Quramy/prisma-fabbrica
Pull request #250 (2024-01-10 01:38:24)

refactor: Replace _factoryFor key to Symbol


Patch:
diff --git a/examples/example-prj/src/__generated__/fabbrica/index.d.ts b/examples/example-prj/src/__generated__/fabbrica/index.d.ts
index 394bbdf..c18f7c9 100644
--- a/examples/example-prj/src/__generated__/fabbrica/index.d.ts
+++ b/examples/example-prj/src/__generated__/fabbrica/index.d.ts
@@ -5,6 +5,7 @@ import type { Category } from "@prisma/client";
 import { Prisma } from "@prisma/client";
 import { Resolver } from "@quramy/prisma-fabbrica/lib/internal";
 export { initialize, resetSequence, registerScalarFieldValueGenerator, resetScalarFieldValueGenerator } from "@quramy/prisma-fabbrica/lib/internal";
+declare const factoryFor: unique symbol;
 type BuildDataOptions = {
     readonly seq: number;
 };
@@ -27,7 +28,7 @@ type UserFactoryDefineOptions = {
 };
 type UserTraitKeys<TOptions extends UserFactoryDefineOptions> = keyof TOptions["traits"];
 export interface UserFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "User";
+    readonly [factoryFor]: "User";
     build(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.UserCreateInput>[]): PromiseLike<Prisma.UserCreateInput[]>;
@@ -47,7 +48,7 @@ export interface UserFactoryInterface<TOptions extends UserFactoryDefineOptions
  */
 export declare function defineUserFactory<TOptions extends UserFactoryDefineOptions>(options?: TOptions): UserFactoryInterface<TOptions>;
 type PostauthorFactory = {
-    _factoryFor: "User";
+    [factoryFor]: "User";
     build: () => PromiseLike<Prisma.UserCreateNestedOneWithoutPostsInput["create"]>;
 };
 type PostFactoryDefineInput = {
@@ -69,7 +70,7 @@ type PostFactoryDefineOptions = {
 };
 type PostTraitKeys<TOptions extends PostFactoryDefineOptions> = keyof TOptions["traits"];
 export interface PostFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "Post";
+    readonly [factoryFor]: "Post";
     build(inputData?: Partial<Prisma.PostCreateInput>): PromiseLike<Prisma.PostCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.PostCreateInput>): PromiseLike<Prisma.PostCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.PostCreateInput>[]): PromiseLike<Prisma.PostCreateInput[]>;
@@ -89,11 +90,11 @@ export interface PostFactoryInterface<TOptions extends PostFactoryDefineOptions
  */
 export declare function definePostFactory<TOptions extends PostFactoryDefineOptions>(options: TOptions): PostFactoryInterface<TOptions>;
 type CommentpostFactory = {
-    _factoryFor: "Post";
+    [factoryFor]: "Post";
     build: () => PromiseLike<Prisma.PostCreateNestedOneWithoutCommentsInput["create"]>;
 };
 type CommentauthorFactory = {
-    _factoryFor: "User";
+    [factoryFor]: "User";
     build: () => PromiseLike<Prisma.UserCreateNestedOneWithoutCommentsInput["create"]>;
 };
 type CommentFactoryDefineInput = {
@@ -114,7 +115,7 @@ type CommentFactoryDefineOptions = {
 };
 type CommentTraitKeys<TOptions extends CommentFactoryDefineOptions> = keyof TOptions["traits"];
 export interface CommentFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "Comment";
+    readonly [factoryFor]: "Comment";
     build(inputData?: Partial<Prisma.CommentCreateInput>): PromiseLike<Prisma.CommentCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.CommentCreateInput>): PromiseLike<Prisma.CommentCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.CommentCreateInput>[]): PromiseLike<Prisma.CommentCreateInput[]>;
@@ -148,7 +149,7 @@ type CategoryFactoryDefineOptions = {
 };
 type CategoryTraitKeys<TOptions extends CategoryFactoryDefineOptions> = keyof TOptions["traits"];
 export interface CategoryFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "Category";
+    readonly [factoryFor]: "Category";
     build(inputData?: Partial<Prisma.CategoryCreateInput>): PromiseLike<Prisma.CategoryCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.CategoryCreateInput>): PromiseLike<Prisma.CategoryCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.CategoryCreateInput>[]): PromiseLike<Prisma.CategoryCreateInput[]>;
diff --git a/examples/example-prj/src/__generated__/fabbrica/index.js b/examples/example-prj/src/__generated__/fabbrica/index.js
index 341e912..8042c9f 100644
--- a/examples/example-prj/src/__generated__/fabbrica/index.js
+++ b/examples/example-prj/src/__generated__/fabbrica/index.js
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "initialize", { enumerable: true, get: function (
 Object.defineProperty(exports, "resetSequence", { enumerable: true, get: function () { return internal_2.resetSequence; } });
 Object.defineProperty(exports, "registerScalarFieldValueGenerator", { enumerable: true, get: function () { return internal_2.registerScalarFieldValueGenerator; } });
 Object.defineProperty(exports, "resetScalarFieldValueGenerator", { enumerable: true, get: function () { return internal_2.resetScalarFieldValueGenerator; } });
+const factoryFor = Symbol("factoryFor");
 const modelFieldDefinitions = [{
         name: "User",
         fields: [{
@@ -92,7 +93,7 @@ function defineUserFactoryInternal({ defaultData: defaultDataResolver, traits: t
         const createList = (inputData) => Promise.all((0, internal_1.normalizeList)(inputData).map(data => create(data)));
         const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "User",
+            [factoryFor]: "User",
             build,
             buildList,
             buildCreateInput: build,
@@ -122,7 +123,7 @@ function defineUserFactory(options) {
 }
 exports.defineUserFactory = defineUserFactory;
 function isPostauthorFactory(x) {
-    return x?._factoryFor === "User";
+    return x?.[factoryFor] === "User";
 }
 function autoGeneratePostScalarsOrEnums({ seq }) {
     return {
@@ -167,7 +168,7 @@ function definePostFactoryInternal({ defaultData: defaultDataResolver, traits: t
         const createList = (inputData) => Promise.all((0, internal_1.normalizeList)(inputData).map(data => create(data)));
         const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "Post",
+            [factoryFor]: "Post",
             build,
             buildList,
             buildCreateInput: build,
@@ -197,10 +198,10 @@ function definePostFactory(options) {
 }
 exports.definePostFactory = definePostFactory;
 function isCommentpostFactory(x) {
-    return x?._factoryFor === "Post";
+    return x?.[factoryFor] === "Post";
 }
 function isCommentauthorFactory(x) {
-    return x?._factoryFor === "User";
+    return x?.[factoryFor] === "User";
 }
 function autoGenerateCommentScalarsOrEnums({ seq }) {
     return {
@@ -248,7 +249,7 @@ function defineCommentFactoryInternal({ defaultData: defaultDataResolver, traits
         const createList = (inputData) => Promise.all((0, internal_1.normalizeList)(inputData).map(data => create(data)));
         const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "Comment",
+            [factoryFor]: "Comment",
             build,
             buildList,
             buildCreateInput: build,
@@ -316,7 +317,7 @@ function defineCategoryFactoryInternal({ defaultData: defaultDataResolver, trait
         const createList = (inputData) => Promise.all((0, internal_1.normalizeList)(inputData).map(data => create(data)));
         const createForConnect = (inputData = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "Category",
+            [factoryFor]: "Category",
             build,
             buildList,
             buildCreateInput: build,
diff --git a/packages/prisma-fabbrica/src/templates/index.ts b/packages/prisma-fabbrica/src/templates/index.ts
index 7d15d7c..5ff39e3 100644
--- a/packages/prisma-fabbrica/src/templates/index.ts
+++ b/packages/prisma-fabbrica/src/templates/index.ts
@@ -105,6 +105,11 @@ export const importStatement = (specifier: string, prismaClientModuleSpecifier:
     import type { ${() => ast.identifier(specifier)} } from ${() => ast.stringLiteral(prismaClientModuleSpecifier)};
   `();
 
+export const symbols = () =>
+  template.statement`
+    const factoryFor = Symbol("factoryFor");
+  `();
+
 export const modelFieldDefinitions = (models: DMMF.Model[]) =>
   template.statement`
     const modelFieldDefinitions: ModelWithFields[] = ${() => createJSONLiteral(createFieldDefinitions(models))};
@@ -190,7 +195,7 @@ export const modelBelongsToRelationFactory = (fieldType: DMMF.SchemaArg, model:
   const targetModel = model.fields.find(byName(fieldType))!;
   return template.statement<ts.TypeAliasDeclaration>`
     type ${() => ast.identifier(`${model.name}${fieldType.name}Factory`)} = {
-      _factoryFor: ${() => ast.literalTypeNode(ast.stringLiteral(targetModel.type))};
+      [factoryFor]: ${() => ast.literalTypeNode(ast.stringLiteral(targetModel.type))};
       build: () => PromiseLike<Prisma.${() => ast.identifier(fieldType.inputTypes[0].type as string)}["create"]>;
     };
   `();
@@ -258,7 +263,7 @@ export const modelTraitKeys = (model: DMMF.Model) =>
 export const modelFactoryInterfaceWithoutTraits = (model: DMMF.Model) =>
   template.statement`
     export interface MODEL_FACTORY_INTERFACE_WITHOUT_TRAITS {
-      readonly _factoryFor: ${() => ast.literalTypeNode(ast.stringLiteral(model.name))}
+      readonly [factoryFor]: ${() => ast.literalTypeNode(ast.stringLiteral(model.name))}
       build(inputData?: Partial<Prisma.MODEL_CREATE_INPUT>): PromiseLike<Prisma.MODEL_CREATE_INPUT>
       buildCreateInput(inputData?: Partial<Prisma.MODEL_CREATE_INPUT>): PromiseLike<Prisma.MODEL_CREATE_INPUT>
       buildList(inputData: number | readonly Partial<Prisma.MODEL_CREATE_INPUT>[]): PromiseLike<Prisma.MODEL_CREATE_INPUT[]>
@@ -295,7 +300,7 @@ export const isModelAssociationFactory = (fieldType: DMMF.SchemaArg, model: DMMF
       x: MODEL_BELONGS_TO_RELATION_FACTORY | ${() =>
         argInputType(model, fieldType.name, fieldType.inputTypes[0])} | undefined
     ): x is MODEL_BELONGS_TO_RELATION_FACTORY {
-      return (x as any)?._factoryFor === ${() => ast.stringLiteral(targetModel.type)};
+      return (x as any)?.[factoryFor] === ${() => ast.stringLiteral(targetModel.type)};
     }
   `({
     MODEL_BELONGS_TO_RELATION_FACTORY: ast.typeReferenceNode(`${model.name}${fieldType.name}Factory`),
@@ -421,7 +426,7 @@ export const defineModelFactoryInternal = (model: DMMF.Model, inputType: DMMF.In
         const createForConnect = (inputData: Partial<Prisma.MODEL_CREATE_INPUT> = {}) => create(inputData).then(pickForConnect);
 
         return {
-          _factoryFor: ${() => ast.stringLiteral(model.name)} as const,
+          [factoryFor]: ${() => ast.stringLiteral(model.name)} as const,
           build,
           buildList,
           buildCreateInput: build,
@@ -508,6 +513,7 @@ export function getSourceFile({
     ...modelEnums.map(enumName => importStatement(enumName, prismaClientModuleSpecifier)),
     ...header(prismaClientModuleSpecifier).statements,
     insertLeadingBreakMarker(buildDataOptions()),
+    insertLeadingBreakMarker(symbols()),
     insertLeadingBreakMarker(modelFieldDefinitions(document.datamodel.models)),
     ...document.datamodel.models
       .reduce((acc, model) => {


Test patch:
diff --git a/packages/artifact-testing/fixtures/field-variation/__generated__/fabbrica/index.ts b/packages/artifact-testing/fixtures/field-variation/__generated__/fabbrica/index.ts
index 3f79b45..4b49c9e 100644
--- a/packages/artifact-testing/fixtures/field-variation/__generated__/fabbrica/index.ts
+++ b/packages/artifact-testing/fixtures/field-variation/__generated__/fabbrica/index.ts
@@ -13,6 +13,8 @@ type BuildDataOptions = {
     readonly seq: number;
 };
 
+const factoryFor = Symbol("factoryFor");
+
 const modelFieldDefinitions: ModelWithFields[] = [{
         name: "User",
         fields: []
@@ -55,7 +57,7 @@ type UserFactoryDefineOptions = {
 type UserTraitKeys<TOptions extends UserFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface UserFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "User";
+    readonly [factoryFor]: "User";
     build(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.UserCreateInput>[]): PromiseLike<Prisma.UserCreateInput[]>;
@@ -111,7 +113,7 @@ function defineUserFactoryInternal<TOptions extends UserFactoryDefineOptions>({
         const createList = (inputData: number | readonly Partial<Prisma.UserCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.UserCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "User" as const,
+            [factoryFor]: "User" as const,
             build,
             buildList,
             buildCreateInput: build,
@@ -163,7 +165,7 @@ type ComplexIdModelFactoryDefineOptions = {
 type ComplexIdModelTraitKeys<TOptions extends ComplexIdModelFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface ComplexIdModelFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "ComplexIdModel";
+    readonly [factoryFor]: "ComplexIdModel";
     build(inputData?: Partial<Prisma.ComplexIdModelCreateInput>): PromiseLike<Prisma.ComplexIdModelCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.ComplexIdModelCreateInput>): PromiseLike<Prisma.ComplexIdModelCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.ComplexIdModelCreateInput>[]): PromiseLike<Prisma.ComplexIdModelCreateInput[]>;
@@ -220,7 +222,7 @@ function defineComplexIdModelFactoryInternal<TOptions extends ComplexIdModelFact
         const createList = (inputData: number | readonly Partial<Prisma.ComplexIdModelCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.ComplexIdModelCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "ComplexIdModel" as const,
+            [factoryFor]: "ComplexIdModel" as const,
             build,
             buildList,
             buildCreateInput: build,
@@ -296,7 +298,7 @@ type FieldTypePatternModelFactoryDefineOptions = {
 type FieldTypePatternModelTraitKeys<TOptions extends FieldTypePatternModelFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface FieldTypePatternModelFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "FieldTypePatternModel";
+    readonly [factoryFor]: "FieldTypePatternModel";
     build(inputData?: Partial<Prisma.FieldTypePatternModelCreateInput>): PromiseLike<Prisma.FieldTypePatternModelCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.FieldTypePatternModelCreateInput>): PromiseLike<Prisma.FieldTypePatternModelCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.FieldTypePatternModelCreateInput>[]): PromiseLike<Prisma.FieldTypePatternModelCreateInput[]>;
@@ -359,7 +361,7 @@ function defineFieldTypePatternModelFactoryInternal<TOptions extends FieldTypePa
         const createList = (inputData: number | readonly Partial<Prisma.FieldTypePatternModelCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.FieldTypePatternModelCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "FieldTypePatternModel" as const,
+            [factoryFor]: "FieldTypePatternModel" as const,
             build,
             buildList,
             buildCreateInput: build,
@@ -409,7 +411,7 @@ type NoPkModelFactoryDefineOptions = {
 type NoPkModelTraitKeys<TOptions extends NoPkModelFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface NoPkModelFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "NoPkModel";
+    readonly [factoryFor]: "NoPkModel";
     build(inputData?: Partial<Prisma.NoPkModelCreateInput>): PromiseLike<Prisma.NoPkModelCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.NoPkModelCreateInput>): PromiseLike<Prisma.NoPkModelCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.NoPkModelCreateInput>[]): PromiseLike<Prisma.NoPkModelCreateInput[]>;
@@ -464,7 +466,7 @@ function defineNoPkModelFactoryInternal<TOptions extends NoPkModelFactoryDefineO
         const createList = (inputData: number | readonly Partial<Prisma.NoPkModelCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.NoPkModelCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "NoPkModel" as const,
+            [factoryFor]: "NoPkModel" as const,
             build,
             buildList,
             buildCreateInput: build,
diff --git a/packages/artifact-testing/fixtures/relations-many-to-many/__generated__/fabbrica/index.ts b/packages/artifact-testing/fixtures/relations-many-to-many/__generated__/fabbrica/index.ts
index d5dbef1..f7a7436 100644
--- a/packages/artifact-testing/fixtures/relations-many-to-many/__generated__/fabbrica/index.ts
+++ b/packages/artifact-testing/fixtures/relations-many-to-many/__generated__/fabbrica/index.ts
@@ -9,6 +9,8 @@ type BuildDataOptions = {
     readonly seq: number;
 };
 
+const factoryFor = Symbol("factoryFor");
+
 const modelFieldDefinitions: ModelWithFields[] = [{
         name: "Post",
         fields: [{
@@ -48,7 +50,7 @@ type PostFactoryDefineOptions = {
 type PostTraitKeys<TOptions extends PostFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface PostFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "Post";
+    readonly [factoryFor]: "Post";
     build(inputData?: Partial<Prisma.PostCreateInput>): PromiseLike<Prisma.PostCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.PostCreateInput>): PromiseLike<Prisma.PostCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.PostCreateInput>[]): PromiseLike<Prisma.PostCreateInput[]>;
@@ -104,7 +106,7 @@ function definePostFactoryInternal<TOptions extends PostFactoryDefineOptions>({
         const createList = (inputData: number | readonly Partial<Prisma.PostCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.PostCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "Post" as const,
+            [factoryFor]: "Post" as const,
             build,
             buildList,
             buildCreateInput: build,
@@ -157,7 +159,7 @@ type CategoryFactoryDefineOptions = {
 type CategoryTraitKeys<TOptions extends CategoryFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface CategoryFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "Category";
+    readonly [factoryFor]: "Category";
     build(inputData?: Partial<Prisma.CategoryCreateInput>): PromiseLike<Prisma.CategoryCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.CategoryCreateInput>): PromiseLike<Prisma.CategoryCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.CategoryCreateInput>[]): PromiseLike<Prisma.CategoryCreateInput[]>;
@@ -213,7 +215,7 @@ function defineCategoryFactoryInternal<TOptions extends CategoryFactoryDefineOpt
         const createList = (inputData: number | readonly Partial<Prisma.CategoryCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.CategoryCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "Category" as const,
+            [factoryFor]: "Category" as const,
             build,
             buildList,
             buildCreateInput: build,
diff --git a/packages/artifact-testing/fixtures/relations-one-to-many/__generated__/fabbrica/index.ts b/packages/artifact-testing/fixtures/relations-one-to-many/__generated__/fabbrica/index.ts
index 2c8625c..f74c006 100644
--- a/packages/artifact-testing/fixtures/relations-one-to-many/__generated__/fabbrica/index.ts
+++ b/packages/artifact-testing/fixtures/relations-one-to-many/__generated__/fabbrica/index.ts
@@ -10,6 +10,8 @@ type BuildDataOptions = {
     readonly seq: number;
 };
 
+const factoryFor = Symbol("factoryFor");
+
 const modelFieldDefinitions: ModelWithFields[] = [{
         name: "User",
         fields: [{
@@ -69,7 +71,7 @@ type UserFactoryDefineOptions = {
 type UserTraitKeys<TOptions extends UserFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface UserFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "User";
+    readonly [factoryFor]: "User";
     build(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.UserCreateInput>[]): PromiseLike<Prisma.UserCreateInput[]>;
@@ -125,7 +127,7 @@ function defineUserFactoryInternal<TOptions extends UserFactoryDefineOptions>({
         const createList = (inputData: number | readonly Partial<Prisma.UserCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.UserCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "User" as const,
+            [factoryFor]: "User" as const,
             build,
             buildList,
             buildCreateInput: build,
@@ -161,7 +163,7 @@ type PostScalarOrEnumFields = {
 };
 
 type PostauthorFactory = {
-    _factoryFor: "User";
+    [factoryFor]: "User";
     build: () => PromiseLike<Prisma.UserCreateNestedOneWithoutPostsInput["create"]>;
 };
 
@@ -182,13 +184,13 @@ type PostFactoryDefineOptions = {
 };
 
 function isPostauthorFactory(x: PostauthorFactory | Prisma.UserCreateNestedOneWithoutPostsInput | undefined): x is PostauthorFactory {
-    return (x as any)?._factoryFor === "User";
+    return (x as any)?.[factoryFor] === "User";
 }
 
 type PostTraitKeys<TOptions extends PostFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface PostFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "Post";
+    readonly [factoryFor]: "Post";
     build(inputData?: Partial<Prisma.PostCreateInput>): PromiseLike<Prisma.PostCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.PostCreateInput>): PromiseLike<Prisma.PostCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.PostCreateInput>[]): PromiseLike<Prisma.PostCreateInput[]>;
@@ -248,7 +250,7 @@ function definePostFactoryInternal<TOptions extends PostFactoryDefineOptions>({
         const createList = (inputData: number | readonly Partial<Prisma.PostCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.PostCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "Post" as const,
+            [factoryFor]: "Post" as const,
             build,
             buildList,
             buildCreateInput: build,
@@ -284,12 +286,12 @@ type ReviewScalarOrEnumFields = {
 };
 
 type ReviewpostFactory = {
-    _factoryFor: "Post";
+    [factoryFor]: "Post";
     build: () => PromiseLike<Prisma.PostCreateNestedOneWithoutReviewsInput["create"]>;
 };
 
 type ReviewreviewerFactory = {
-    _factoryFor: "User";
+    [factoryFor]: "User";
     build: () => PromiseLike<Prisma.UserCreateNestedOneWithoutReviewsInput["create"]>;
 };
 
@@ -310,17 +312,17 @@ type ReviewFactoryDefineOptions = {
 };
 
 function isReviewpostFactory(x: ReviewpostFactory | Prisma.PostCreateNestedOneWithoutReviewsInput | undefined): x is ReviewpostFactory {
-    return (x as any)?._factoryFor === "Post";
+    return (x as any)?.[factoryFor] === "Post";
 }
 
 function isReviewreviewerFactory(x: ReviewreviewerFactory | Prisma.UserCreateNestedOneWithoutReviewsInput | undefined): x is ReviewreviewerFactory {
-    return (x as any)?._factoryFor === "User";
+    return (x as any)?.[factoryFor] === "User";
 }
 
 type ReviewTraitKeys<TOptions extends ReviewFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface ReviewFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "Review";
+    readonly [factoryFor]: "Review";
     build(inputData?: Partial<Prisma.ReviewCreateInput>): PromiseLike<Prisma.ReviewCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.ReviewCreateInput>): PromiseLike<Prisma.ReviewCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.ReviewCreateInput>[]): PromiseLike<Prisma.ReviewCreateInput[]>;
@@ -383,7 +385,7 @@ function defineReviewFactoryInternal<TOptions extends ReviewFactoryDefineOptions
         const createList = (inputData: number | readonly Partial<Prisma.ReviewCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.ReviewCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "Review" as const,
+            [factoryFor]: "Review" as const,
             build,
             buildList,
             buildCreateInput: build,
diff --git a/packages/artifact-testing/fixtures/relations-one-to-one/__generated__/fabbrica/index.ts b/packages/artifact-testing/fixtures/relations-one-to-one/__generated__/fabbrica/index.ts
index de7166e..b87e245 100644
--- a/packages/artifact-testing/fixtures/relations-one-to-one/__generated__/fabbrica/index.ts
+++ b/packages/artifact-testing/fixtures/relations-one-to-one/__generated__/fabbrica/index.ts
@@ -9,6 +9,8 @@ type BuildDataOptions = {
     readonly seq: number;
 };
 
+const factoryFor = Symbol("factoryFor");
+
 const modelFieldDefinitions: ModelWithFields[] = [{
         name: "User",
         fields: [{
@@ -31,7 +33,7 @@ type UserScalarOrEnumFields = {
 };
 
 type UserprofileFactory = {
-    _factoryFor: "Profile";
+    [factoryFor]: "Profile";
     build: () => PromiseLike<Prisma.ProfileCreateNestedOneWithoutUserInput["create"]>;
 };
 
@@ -51,13 +53,13 @@ type UserFactoryDefineOptions = {
 };
 
 function isUserprofileFactory(x: UserprofileFactory | Prisma.ProfileCreateNestedOneWithoutUserInput | undefined): x is UserprofileFactory {
-    return (x as any)?._factoryFor === "Profile";
+    return (x as any)?.[factoryFor] === "Profile";
 }
 
 type UserTraitKeys<TOptions extends UserFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface UserFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "User";
+    readonly [factoryFor]: "User";
     build(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.UserCreateInput>[]): PromiseLike<Prisma.UserCreateInput[]>;
@@ -117,7 +119,7 @@ function defineUserFactoryInternal<TOptions extends UserFactoryDefineOptions>({
         const createList = (inputData: number | readonly Partial<Prisma.UserCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.UserCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "User" as const,
+            [factoryFor]: "User" as const,
             build,
             buildList,
             buildCreateInput: build,
@@ -152,7 +154,7 @@ type ProfileScalarOrEnumFields = {
 };
 
 type ProfileuserFactory = {
-    _factoryFor: "User";
+    [factoryFor]: "User";
     build: () => PromiseLike<Prisma.UserCreateNestedOneWithoutProfileInput["create"]>;
 };
 
@@ -171,13 +173,13 @@ type ProfileFactoryDefineOptions = {
 };
 
 function isProfileuserFactory(x: ProfileuserFactory | Prisma.UserCreateNestedOneWithoutProfileInput | undefined): x is ProfileuserFactory {
-    return (x as any)?._factoryFor === "User";
+    return (x as any)?.[factoryFor] === "User";
 }
 
 type ProfileTraitKeys<TOptions extends ProfileFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface ProfileFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "Profile";
+    readonly [factoryFor]: "Profile";
     build(inputData?: Partial<Prisma.ProfileCreateInput>): PromiseLike<Prisma.ProfileCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.ProfileCreateInput>): PromiseLike<Prisma.ProfileCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.ProfileCreateInput>[]): PromiseLike<Prisma.ProfileCreateInput[]>;
@@ -236,7 +238,7 @@ function defineProfileFactoryInternal<TOptions extends ProfileFactoryDefineOptio
         const createList = (inputData: number | readonly Partial<Prisma.ProfileCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.ProfileCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "Profile" as const,
+            [factoryFor]: "Profile" as const,
             build,
             buildList,
             buildCreateInput: build,
diff --git a/packages/artifact-testing/fixtures/simple-model/__generated__/fabbrica/index.ts b/packages/artifact-testing/fixtures/simple-model/__generated__/fabbrica/index.ts
index 82d39a0..75fb819 100644
--- a/packages/artifact-testing/fixtures/simple-model/__generated__/fabbrica/index.ts
+++ b/packages/artifact-testing/fixtures/simple-model/__generated__/fabbrica/index.ts
@@ -8,6 +8,8 @@ type BuildDataOptions = {
     readonly seq: number;
 };
 
+const factoryFor = Symbol("factoryFor");
+
 const modelFieldDefinitions: ModelWithFields[] = [{
         name: "User",
         fields: []
@@ -35,7 +37,7 @@ type UserFactoryDefineOptions = {
 type UserTraitKeys<TOptions extends UserFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface UserFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "User";
+    readonly [factoryFor]: "User";
     build(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.UserCreateInput>[]): PromiseLike<Prisma.UserCreateInput[]>;
@@ -91,7 +93,7 @@ function defineUserFactoryInternal<TOptions extends UserFactoryDefineOptions>({
         const createList = (inputData: number | readonly Partial<Prisma.UserCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.UserCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "User" as const,
+            [factoryFor]: "User" as const,
             build,
             buildList,
             buildCreateInput: build,
diff --git a/packages/prisma-fabbrica/src/templates/__snapshots__/getSourceFile.test.ts.snap b/packages/prisma-fabbrica/src/templates/__snapshots__/getSourceFile.test.ts.snap
index 4710b08..d9f1c57 100644
--- a/packages/prisma-fabbrica/src/templates/__snapshots__/getSourceFile.test.ts.snap
+++ b/packages/prisma-fabbrica/src/templates/__snapshots__/getSourceFile.test.ts.snap
@@ -11,6 +11,8 @@ type BuildDataOptions = {
     readonly seq: number;
 };
 
+const factoryFor = Symbol("factoryFor");
+
 const modelFieldDefinitions: ModelWithFields[] = [{
         name: "User",
         fields: []
@@ -38,7 +40,7 @@ type UserFactoryDefineOptions = {
 type UserTraitKeys<TOptions extends UserFactoryDefineOptions> = keyof TOptions["traits"];
 
 export interface UserFactoryInterfaceWithoutTraits {
-    readonly _factoryFor: "User";
+    readonly [factoryFor]: "User";
     build(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildCreateInput(inputData?: Partial<Prisma.UserCreateInput>): PromiseLike<Prisma.UserCreateInput>;
     buildList(inputData: number | readonly Partial<Prisma.UserCreateInput>[]): PromiseLike<Prisma.UserCreateInput[]>;
@@ -94,7 +96,7 @@ function defineUserFactoryInternal<TOptions extends UserFactoryDefineOptions>({
         const createList = (inputData: number | readonly Partial<Prisma.UserCreateInput>[]) => Promise.all(normalizeList(inputData).map(data => create(data)));
         const createForConnect = (inputData: Partial<Prisma.UserCreateInput> = {}) => create(inputData).then(pickForConnect);
         return {
-            _factoryFor: "User" as const,
+            [factoryFor]: "User" as const,
             build,
             buildList,
             buildCreateInput: build,