From 569d0213165509c8becad8984ed83bb5da4c7799 Mon Sep 17 00:00:00 2001 From: dswbx Date: Wed, 1 Oct 2025 09:00:44 +0200 Subject: [PATCH] fix: update OneToOneRelation and PolymorphicRelation configurations Enhanced OneToOneRelation to allow source to create target with a mapping field and added a limit. Updated PolymorphicRelation to return a TextField for entity_id instead of NumberField, improving type consistency. --- app/package.json | 2 +- app/src/data/relations/OneToOneRelation.ts | 2 ++ app/src/data/relations/PolymorphicRelation.ts | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/package.json b/app/package.json index 6410f21..a4c0ff3 100644 --- a/app/package.json +++ b/app/package.json @@ -40,7 +40,7 @@ "test:coverage": "ALL_TESTS=1 bun test --bail --coverage", "test:vitest:coverage": "vitest run --coverage", "test:e2e": "playwright test", - "test:e2e:adapters": "bun run e2e/adapters.ts", + "test:e2e:adapters": "NODE_NO_WARNINGS=1 bun run e2e/adapters.ts", "test:e2e:ui": "VITE_DB_URL=:memory: playwright test --ui", "test:e2e:debug": "VITE_DB_URL=:memory: playwright test --debug", "test:e2e:report": "VITE_DB_URL=:memory: playwright show-report", diff --git a/app/src/data/relations/OneToOneRelation.ts b/app/src/data/relations/OneToOneRelation.ts index 0cd64a4..9204a5a 100644 --- a/app/src/data/relations/OneToOneRelation.ts +++ b/app/src/data/relations/OneToOneRelation.ts @@ -5,6 +5,7 @@ import { type RelationType, RelationTypes } from "./relation-types"; /** * Both source and target receive a mapping field + * Source gets the mapping field, and can $create the target * @todo: determine if it should be removed */ export type OneToOneRelationConfig = ManyToOneRelationConfig; @@ -17,6 +18,7 @@ export class OneToOneRelation extends ManyToOneRelation { inversedBy, sourceCardinality: 1, required, + with_limit: 1, }); } diff --git a/app/src/data/relations/PolymorphicRelation.ts b/app/src/data/relations/PolymorphicRelation.ts index 25b8705..803c8c8 100644 --- a/app/src/data/relations/PolymorphicRelation.ts +++ b/app/src/data/relations/PolymorphicRelation.ts @@ -102,8 +102,8 @@ export class PolymorphicRelation extends EntityRelation) {