Skip to content

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

fix(studio): show column format in sort/filter type labels (#48201)

Danny White9ea3919fb5af
diff --git a/apps/studio/components/grid/components/header/filter/FilterRow.tsx b/apps/studio/components/grid/components/header/filter/FilterRow.tsx
index 04dafe05db8..6881a292dd0 100644
--- a/apps/studio/components/grid/components/header/filter/FilterRow.tsx
+++ b/apps/studio/components/grid/components/header/filter/FilterRow.tsx
@@ -4,7 +4,9 @@ import { Button, Input } from 'ui'
import { FilterOperatorOptions } from './Filter.constants'
import { DropdownControl } from '@/components/grid/components/common/DropdownControl'
+import { getColumnFormat } from '@/components/grid/components/grid/ColumnHeader.utils'
import type { Filter, FilterOperator } from '@/components/grid/types'
+import { getColumnType } from '@/components/grid/utils/gridColumns'
import { useTableEditorTableStateSnapshot } from '@/state/table-editor-table'
export interface FilterRowProps {
@@ -18,9 +20,15 @@ export interface FilterRowProps {
const FilterRow = ({ filter, filterIdx, onChange, onDelete, onKeyDown }: FilterRowProps) => {
const snap = useTableEditorTableStateSnapshot()
const column = snap.table.columns.find((x) => x.name === filter.column)
+ // Prefer display labels that match column headers (format, with arrays as int4[]).
+ // Avoid raw dataType, which is "USER-DEFINED" for extension types like geography.
const columnOptions =
snap.table.columns?.map((x) => {
- return { value: x.name, label: x.name, postLabel: x.dataType }
+ return {
+ value: x.name,
+ label: x.name,
+ postLabel: getColumnFormat(getColumnType(x), x.format),
+ }
}) || []
const placeholder =
diff --git a/apps/studio/components/grid/components/header/sort/SortPopoverPrimitive.tsx b/apps/studio/components/grid/components/header/sort/SortPopoverPrimitive.tsx
index 350898ed730..30570a092e6 100644
--- a/apps/studio/components/grid/components/header/sort/SortPopoverPrimitive.tsx
+++ b/apps/studio/components/grid/components/header/sort/SortPopoverPrimitive.tsx
@@ -23,8 +23,10 @@ import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'
import { DropdownControl } from '../../common/DropdownControl'
import SortRow from './SortRow'
+import { getColumnFormat } from '@/components/grid/components/grid/ColumnHeader.utils'
import { useTableFilter } from '@/components/grid/hooks/useTableFilter'
import type { Sort } from '@/components/grid/types'
+import { getColumnType } from '@/components/grid/utils/gridColumns'
import { InlineLink } from '@/components/ui/InlineLink'
import { useTableRowsCountQuery } from '@/data/table-rows/table-rows-count-query'
import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
@@ -105,13 +107,14 @@ export const SortPopoverPrimitive = ({
})
}, [snap?.table?.columns, localSorts])
- // Format the columns for the dropdown
+ // Prefer display labels that match column headers (format, with arrays as int4[]).
+ // Avoid raw dataType, which is "USER-DEFINED" for extension types like geography.
const dropdownOptions = useMemo(() => {
return (
columns?.map((x) => ({
value: x.name,
label: x.name,
- postLabel: x.dataType,
+ postLabel: getColumnFormat(getColumnType(x), x.format),
disabled: x.dataType === 'json' || x.dataType === 'jsonb',
tooltip:
x.dataType === 'json' || x.dataType === 'jsonb'