Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes invoice table re-ordering results on render and pagination due to order being random #531

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dashboard/final-example/app/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down Expand Up @@ -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}
`;

Expand Down
4 changes: 2 additions & 2 deletions dashboard/starter-example/app/lib/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => ({
Expand Down Expand Up @@ -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}
`;

Expand Down