Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: Disable sorting by json/jsonb columns (#28395)

Ivan Vasilove094a3617754
diff --git a/apps/studio/components/grid/components/header/sort/SortPopover.tsx b/apps/studio/components/grid/components/header/sort/SortPopover.tsx
index 39e1811aa51..6d86f88d715 100644
--- a/apps/studio/components/grid/components/header/sort/SortPopover.tsx
+++ b/apps/studio/components/grid/components/header/sort/SortPopover.tsx
@@ -69,6 +69,11 @@ const SortOverlay = ({ table, sorts: sortsFromUrl, onApplySorts }: SortOverlayPr
const [sorts, setSorts] = useState<Sort[]>(initialSorts)
const columns = table.columns!.filter((x) => {
+ // exclude json/jsonb columns from sorting. Sorting by json fields in PG is only possible if you provide key from
+ // the JSON object.
+ if (x.dataType === 'json' || x.dataType === 'jsonb') {
+ return false
+ }
const found = sorts.find((y) => y.column == x.name)
return !found
})