Skip to content

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

Table editor filter convert empty string value to null if column is not text based type (#34674)

Joshen Lim06091157d90b
diff --git a/apps/studio/components/grid/components/grid/Grid.tsx b/apps/studio/components/grid/components/grid/Grid.tsx
index aa9af80bd82..4cda2fe55f7 100644
--- a/apps/studio/components/grid/components/grid/Grid.tsx
+++ b/apps/studio/components/grid/components/grid/Grid.tsx
@@ -155,7 +155,14 @@ export const Grid = memo(
{isLoading && <TableGridInnerLoadingState />}
{isError && (
<div className="p-2 col-span-full">
- <AlertError error={error} subject="Failed to retrieve rows from table" />
+ <AlertError error={error} subject="Failed to retrieve rows from table">
+ {filters.length > 0 && (
+ <p>
+ Verify that the filter values are correct, as the error may stem from an
+ incorrectly applied filter
+ </p>
+ )}
+ </AlertError>
</div>
)}
{isSuccess && (
diff --git a/apps/studio/components/ui/AlertError.tsx b/apps/studio/components/ui/AlertError.tsx
index a01ec4646d8..5dd87e64ea2 100644
--- a/apps/studio/components/ui/AlertError.tsx
+++ b/apps/studio/components/ui/AlertError.tsx
@@ -1,6 +1,6 @@
import Link from 'next/link'
+import { PropsWithChildren } from 'react'
-import type { ResponseError } from 'types'
import {
AlertDescription_Shadcn_,
AlertTitle_Shadcn_,
@@ -25,7 +25,8 @@ const AlertError = ({
error,
className,
showIcon = true,
-}: AlertErrorProps) => {
+ children,
+}: PropsWithChildren<AlertErrorProps>) => {
const subjectString = subject?.replace(/ /g, '%20')
let href = `/support/new?category=dashboard_bug`
@@ -49,11 +50,10 @@ const AlertError = ({
support.
</p>
</div>
- <div>
- <Button asChild type="warning">
- <Link href={href}>Contact support</Link>
- </Button>
- </div>
+ {children}
+ <Button asChild type="warning" className="w-min">
+ <Link href={href}>Contact support</Link>
+ </Button>
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
)
diff --git a/packages/pg-meta/src/query/table-row-query.ts b/packages/pg-meta/src/query/table-row-query.ts
index 82cf5202830..fe20c3f99c9 100644
--- a/packages/pg-meta/src/query/table-row-query.ts
+++ b/packages/pg-meta/src/query/table-row-query.ts
@@ -1,10 +1,10 @@
import { ident } from '../pg-format'
-import { PGTable } from '../pg-meta-tables'
-import { Query } from './Query'
-import { Sort, Filter } from './types'
-import { PGView } from '../pg-meta-views'
import { PGForeignTable } from '../pg-meta-foreign-tables'
import { PGMaterializedView } from '../pg-meta-materialized-views'
+import { PGTable } from '../pg-meta-tables'
+import { PGView } from '../pg-meta-views'
+import { Query } from './Query'
+import { Filter, Sort } from './types'
// Constants
export const MAX_CHARACTERS = 10 * 1024 // 10KB
@@ -172,7 +172,13 @@ export const getTableRowsSql = ({
let queryChains = query.from(table.name, table.schema).select(selectClause)
filters.forEach((x) => {
- queryChains = queryChains.filter(x.column, x.operator, x.value)
+ const col = table.columns?.find((y) => y.name === x.column)
+ const isStringTypeColumn = !!col ? TEXT_TYPES.includes(col.format) : true
+ queryChains = queryChains.filter(
+ x.column,
+ x.operator,
+ !isStringTypeColumn && x.value === '' ? null : x.value
+ )
})
// If sorts is empty and table row count is within threshold, use the primary key as the default sort