From 6b15f4ba888772bd5fec842bfba66f7d878a891b Mon Sep 17 00:00:00 2001 From: Gregor Becker Date: Mon, 18 Sep 2023 14:04:58 +0200 Subject: [PATCH 1/3] release: pinia-orm@1.7.2 --- packages/pinia-orm/CHANGELOG.md | 6 ++++++ packages/pinia-orm/package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/pinia-orm/CHANGELOG.md b/packages/pinia-orm/CHANGELOG.md index 6bf6f83ce..ed8812898 100644 --- a/packages/pinia-orm/CHANGELOG.md +++ b/packages/pinia-orm/CHANGELOG.md @@ -1,3 +1,9 @@ +## [1.7.2](https://github.com/CodeDredd/pinia-orm/compare/pinia-orm@1.7.1...pinia-orm@1.7.2) (2023-09-18) + +### Bug Fixes + +- Export for "dist" is broken ([a3c734e](https://github.com/CodeDredd/pinia-orm/commit/a3c734ee9eb29f8403b069a1b41fbc1a88f1721a)) + ## [1.7.1](https://github.com/CodeDredd/pinia-orm/compare/pinia-orm@1.7.0...pinia-orm@1.7.1) (2023-09-18) ### Bug Fixes diff --git a/packages/pinia-orm/package.json b/packages/pinia-orm/package.json index 4916084e8..c75199cc7 100644 --- a/packages/pinia-orm/package.json +++ b/packages/pinia-orm/package.json @@ -1,6 +1,6 @@ { "name": "pinia-orm", - "version": "1.7.1", + "version": "1.7.2", "description": "The Pinia plugin to enable Object-Relational Mapping access to the Pinia Store.", "keywords": [ "vue", From 31357b80222e011f97e0965af4de976456dc51be Mon Sep 17 00:00:00 2001 From: Maksim Kutishchev Date: Sun, 14 Apr 2024 18:45:59 +0400 Subject: [PATCH 2/3] Fix HasMany relation with complex keys --- .../src/model/attributes/relations/HasMany.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/pinia-orm/src/model/attributes/relations/HasMany.ts b/packages/pinia-orm/src/model/attributes/relations/HasMany.ts index 65ceba85c..1317620b3 100644 --- a/packages/pinia-orm/src/model/attributes/relations/HasMany.ts +++ b/packages/pinia-orm/src/model/attributes/relations/HasMany.ts @@ -1,4 +1,5 @@ import type { Schema as NormalizrSchema } from '@pinia-orm/normalizr' +import { isArray } from '@/support/Utils' import type { Schema } from '../../../schema/Schema' import type { Collection, Element } from '../../../data/Data' import type { Query } from '../../../query/Query' @@ -76,7 +77,11 @@ export class HasMany extends Relation { const dictionary = this.buildDictionary(query.get(false)) models.forEach((model) => { - const key = model[this.getKey(this.localKey)] + const key = this.getKey( + isArray(this.localKey) + ? this.localKey.map(key => model[key]) + : model[this.localKey] + ) dictionary[key] ? model.$setRelation(relation, dictionary[key]) @@ -89,8 +94,12 @@ export class HasMany extends Relation { */ protected buildDictionary (results: Collection): Dictionary { return this.mapToDictionary(results, (result) => { - const key = this.getKey(this.foreignKey) - return [result[key], result] + const key = this.getKey( + isArray(this.foreignKey) + ? this.foreignKey.map(key => result[key]) + : result[this.foreignKey] + ) + return [key, result] }) } From d44a6386ecc67d7b50c49b16765f25c467b4c51b Mon Sep 17 00:00:00 2001 From: Maksim Kutishchev Date: Sun, 14 Apr 2024 20:24:14 +0400 Subject: [PATCH 3/3] fix isArray import --- packages/pinia-orm/src/model/attributes/relations/HasMany.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pinia-orm/src/model/attributes/relations/HasMany.ts b/packages/pinia-orm/src/model/attributes/relations/HasMany.ts index 1317620b3..74865352a 100644 --- a/packages/pinia-orm/src/model/attributes/relations/HasMany.ts +++ b/packages/pinia-orm/src/model/attributes/relations/HasMany.ts @@ -1,10 +1,10 @@ import type { Schema as NormalizrSchema } from '@pinia-orm/normalizr' -import { isArray } from '@/support/Utils' import type { Schema } from '../../../schema/Schema' import type { Collection, Element } from '../../../data/Data' import type { Query } from '../../../query/Query' import type { Model, PrimaryKey } from '../../Model' import type { Dictionary } from './Relation' +import { isArray } from '../../../support/Utils' import { Relation } from './Relation' export class HasMany extends Relation {