From cb35e6dc9a2a30e5e501337bf075866cda7169a9 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Mon, 7 Oct 2024 13:25:48 -0600 Subject: [PATCH] Only add metadata id for tables that are lacking a primary key --- src/functions/instance/getTableData.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/functions/instance/getTableData.js b/src/functions/instance/getTableData.js index bb89aad85..a94707ae1 100644 --- a/src/functions/instance/getTableData.js +++ b/src/functions/instance/getTableData.js @@ -10,6 +10,7 @@ export default async ({ schema, table, filtered, pageSize, onlyCached, sorted, p let newData = []; let allAttributes = false; let hashAttribute = false; + let get_attributes = ['*'] const offset = page * pageSize; try { @@ -22,7 +23,12 @@ export default async ({ schema, table, filtered, pageSize, onlyCached, sorted, p const { record_count, attributes, hash_attribute } = result; allAttributes = attributes.map((a) => a.attribute); - hashAttribute = hash_attribute ?? '$id'; + if (hash_attribute == undefined) { + hashAttribute = '$id'; + get_attributes = ['$id', '*']; + } else + hashAttribute = hash_attribute; + newTotalRecords = record_count; newTotalPages = newTotalRecords && Math.ceil(newTotalRecords / pageSize); } catch (e) { @@ -36,7 +42,7 @@ export default async ({ schema, table, filtered, pageSize, onlyCached, sorted, p schema, table, operator: 'and', - get_attributes: ['$id', '*'], + get_attributes, limit: pageSize, offset, sort: sorted.length ? { attribute: sorted[0].id, descending: sorted[0].desc } : undefined, @@ -52,7 +58,7 @@ export default async ({ schema, table, filtered, pageSize, onlyCached, sorted, p table, search_attribute: hashAttribute, search_value: '*', - get_attributes: ['$id', '*'], + get_attributes, limit: pageSize, offset, sort: sorted.length ? { attribute: sorted[0].id, descending: sorted[0].desc } : undefined,