From 85827bbf9309a3894b7ab215f8277bda5aaa0f5e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 8 Jul 2024 13:27:30 +0200 Subject: [PATCH] Refactor breakRowIdField --- packages/backend-core/src/sql/sql.ts | 3 +-- packages/backend-core/src/sql/utils.ts | 3 +++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/backend-core/src/sql/sql.ts b/packages/backend-core/src/sql/sql.ts index 615753efc3..c17cbae86f 100644 --- a/packages/backend-core/src/sql/sql.ts +++ b/packages/backend-core/src/sql/sql.ts @@ -217,8 +217,7 @@ class InternalBuilder { if (!opts.relationship && !isRelationshipField) { const alias = getTableAlias(tableName) fn(alias ? `${alias}.${updatedKey}` : updatedKey, value) - } - if (opts.relationship && isRelationshipField) { + } else if (opts.relationship && isRelationshipField) { const [filterTableName, property] = updatedKey.split(".") const alias = getTableAlias(filterTableName) fn(alias ? `${alias}.${property}` : property, value) diff --git a/packages/backend-core/src/sql/utils.ts b/packages/backend-core/src/sql/utils.ts index 45ab510948..4b0ac82ffe 100644 --- a/packages/backend-core/src/sql/utils.ts +++ b/packages/backend-core/src/sql/utils.ts @@ -116,6 +116,9 @@ export function breakRowIdField(_id: string | { _id: string }): any[] { return Array.isArray(parsed) ? parsed : [parsed] } catch (err) { // wasn't json - likely was handlebars for a many to many + if (Array.isArray(_id)) { + return _id + } return [_id] } }