Skip to content

Commit cf2a372

Browse files
authored
Fix default order by columsn to exclude json columns (supabase#39028)
1 parent 7157cc5 commit cf2a372

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

apps/studio/data/table-rows/table-rows-query.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ export interface GetTableRowsArgs {
3535
const getDefaultOrderByColumns = (table: SupaTable) => {
3636
const primaryKeyColumns = table.columns.filter((col) => col?.isPrimaryKey).map((col) => col.name)
3737
if (primaryKeyColumns.length === 0) {
38-
return [table.columns[0]?.name]
38+
const eligibleColumnsForSorting = table.columns.filter((x) => !x.dataType.includes('json'))
39+
if (eligibleColumnsForSorting.length > 0) return [eligibleColumnsForSorting[0]?.name]
40+
else return []
3941
} else {
4042
return primaryKeyColumns
4143
}

packages/pg-meta/src/query/table-row-query.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ export const getDefaultOrderByColumns = (table: Pick<PGTable, 'primary_keys' | '
7777
return primaryKeyColumns
7878
}
7979
if (table.columns && table.columns.length > 0) {
80-
return [table.columns[0].name]
80+
const eligibleColumnsForSorting = table.columns.filter((x) => !x.data_type.includes('json'))
81+
if (eligibleColumnsForSorting.length > 0) return [eligibleColumnsForSorting[0].name]
82+
else return []
8183
}
8284
return []
8385
}

0 commit comments

Comments
 (0)