From 41b72027c4ffee70072c30f7c2341dd0be4f278c Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 3 May 2022 15:52:03 +0100 Subject: [PATCH 1/2] Query preview sort by number for number types --- .../src/components/integration/QueryViewer.svelte | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/builder/src/components/integration/QueryViewer.svelte b/packages/builder/src/components/integration/QueryViewer.svelte index 8f6f9eeb53..81ffa29733 100644 --- a/packages/builder/src/components/integration/QueryViewer.svelte +++ b/packages/builder/src/components/integration/QueryViewer.svelte @@ -44,6 +44,21 @@ $: readQuery = query.queryVerb === "read" || query.readable $: queryInvalid = !query.name || (readQuery && data.length === 0) + //Cast field in query preview response to number if specified by schema + $: { + for (let i = 0; i < data.length; i++) { + let row = data[i] + for (let fieldNameIndex in Object.keys(fields)) { + let fieldName = Object.keys(fields)[fieldNameIndex] + if (fields[fieldName] === "number" && !isNaN(Number(row[fieldName]))) { + row[fieldName] = Number(row[fieldName]) + } else { + row[fieldName] = row[fieldName]?.toString() + } + } + } + } + // seed the transformer if (query && !query.transformer) { query.transformer = "return data" From d1e6e7549a053b9c325e7d5fb47738997b7f736b Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Wed, 4 May 2022 13:33:58 +0100 Subject: [PATCH 2/2] using of --- packages/builder/src/components/integration/QueryViewer.svelte | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/builder/src/components/integration/QueryViewer.svelte b/packages/builder/src/components/integration/QueryViewer.svelte index 81ffa29733..49b9b38d86 100644 --- a/packages/builder/src/components/integration/QueryViewer.svelte +++ b/packages/builder/src/components/integration/QueryViewer.svelte @@ -48,8 +48,7 @@ $: { for (let i = 0; i < data.length; i++) { let row = data[i] - for (let fieldNameIndex in Object.keys(fields)) { - let fieldName = Object.keys(fields)[fieldNameIndex] + for (let fieldName of Object.keys(fields)) { if (fields[fieldName] === "number" && !isNaN(Number(row[fieldName]))) { row[fieldName] = Number(row[fieldName]) } else {