Skip to content

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

add coalesce calls for empty schemas

Alaister Youngeb32e5f6ebf6
diff --git a/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx b/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx
index e71d294b3d5..d074803094f 100644
--- a/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx
+++ b/studio/components/layouts/TableEditorLayout/TableEditorMenu.tsx
@@ -221,7 +221,9 @@ const TableEditorMenu = ({
<div className="flex w-full items-center justify-between">
<div className="flex items-center space-x-1">
<p>Tables</p>
- <p style={{ fontVariantNumeric: 'tabular-nums' }}>({totalCount})</p>
+ {totalCount !== undefined && (
+ <p style={{ fontVariantNumeric: 'tabular-nums' }}>({totalCount})</p>
+ )}
</div>
<button className="cursor-pointer" onClick={refreshTables}>
<IconRefreshCw className={isRefetching ? 'animate-spin' : ''} size={14} />
diff --git a/studio/data/entity-types/entity-types-infinite-query.ts b/studio/data/entity-types/entity-types-infinite-query.ts
index 2fedf6e3c24..20cf2231fe3 100644
--- a/studio/data/entity-types/entity-types-infinite-query.ts
+++ b/studio/data/entity-types/entity-types-infinite-query.ts
@@ -64,7 +64,7 @@ export async function getEntityTypes(
)
select
jsonb_build_object(
- 'entities', jsonb_agg(
+ 'entities', coalesce(jsonb_agg(
jsonb_build_object(
'id', r.id,
'schema', r.schema,
@@ -73,8 +73,8 @@ export async function getEntityTypes(
'comment', r.comment
)
order by r.name asc
- ),
- 'count', min(r.count)
+ ), '[]'::jsonb),
+ 'count', coalesce(min(r.count), 0)
) "data"
from records r;
`