From b2a8eea6a7725c91338bd00f3b90c1a7e32f81bc Mon Sep 17 00:00:00 2001 From: Elliot Sadler Date: Thu, 28 Dec 2023 15:37:47 -0800 Subject: [PATCH 1/2] Fix non-determinstic ORDER BY in invoice fetching --- dashboard/starter-example/app/lib/data.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/starter-example/app/lib/data.ts b/dashboard/starter-example/app/lib/data.ts index 4c699a33..f1e6b4bb 100644 --- a/dashboard/starter-example/app/lib/data.ts +++ b/dashboard/starter-example/app/lib/data.ts @@ -38,7 +38,7 @@ export async function fetchLatestInvoices() { SELECT invoices.amount, customers.name, customers.image_url, customers.email, invoices.id FROM invoices JOIN customers ON invoices.customer_id = customers.id - ORDER BY invoices.date DESC + ORDER BY invoices.date DESC, invoices.id LIMIT 5`; const latestInvoices = data.rows.map((invoice) => ({ @@ -112,7 +112,7 @@ export async function fetchFilteredInvoices( invoices.amount::text ILIKE ${`%${query}%`} OR invoices.date::text ILIKE ${`%${query}%`} OR invoices.status ILIKE ${`%${query}%`} - ORDER BY invoices.date DESC + ORDER BY invoices.date DESC, invoices.id LIMIT ${ITEMS_PER_PAGE} OFFSET ${offset} `; From 226269c49259dc7adc1e7281bb9b5af6f48e677e Mon Sep 17 00:00:00 2001 From: Elliot Sadler Date: Thu, 28 Dec 2023 15:39:27 -0800 Subject: [PATCH 2/2] Update invoice fetching in final-example --- dashboard/final-example/app/lib/data.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard/final-example/app/lib/data.ts b/dashboard/final-example/app/lib/data.ts index 9fb3519e..e9a351eb 100644 --- a/dashboard/final-example/app/lib/data.ts +++ b/dashboard/final-example/app/lib/data.ts @@ -40,7 +40,7 @@ export async function fetchLatestInvoices() { SELECT invoices.amount, customers.name, customers.image_url, customers.email, invoices.id FROM invoices JOIN customers ON invoices.customer_id = customers.id - ORDER BY invoices.date DESC + ORDER BY invoices.date DESC, invoices.id LIMIT 5`; const latestInvoices = data.rows.map((invoice) => ({ @@ -116,7 +116,7 @@ export async function fetchFilteredInvoices( invoices.amount::text ILIKE ${`%${query}%`} OR invoices.date::text ILIKE ${`%${query}%`} OR invoices.status ILIKE ${`%${query}%`} - ORDER BY invoices.date DESC + ORDER BY invoices.date DESC, invoices.id LIMIT ${ITEMS_PER_PAGE} OFFSET ${offset} `;