Skip to content

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

fix: Unable to export data from the table to CSV (#19436)

Austin Tranafa8f5ad9a52
diff --git a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx
index cfac422fbb9..800d249fa89 100644
--- a/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx
+++ b/apps/studio/components/layouts/TableEditorLayout/EntityListItem.tsx
@@ -27,6 +27,7 @@ import { useStore } from 'hooks'
import { BASE_PATH } from 'lib/constants'
import { useTableEditorStateSnapshot } from 'state/table-editor'
import { useProjectContext } from '../ProjectLayout/ProjectContext'
+import { IS_PLATFORM } from 'common'
export interface EntityListItemProps {
id: number
@@ -50,7 +51,8 @@ const EntityListItem = ({ id, projectRef, item: entity, isLocked }: EntityListIt
}
const exportTableAsCSV = async () => {
- if (!project?.connectionString) return console.error('Connection string is required')
+ if (IS_PLATFORM && !project?.connectionString)
+ return console.error('Connection string is required')
const toastId = ui.setNotification({
category: 'loading',
message: `Exporting ${entity.name} as CSV...`,
@@ -60,7 +62,7 @@ const EntityListItem = ({ id, projectRef, item: entity, isLocked }: EntityListIt
const table = await getTable({
id: entity.id,
projectRef,
- connectionString: project.connectionString,
+ connectionString: project?.connectionString,
})
const supaTable =
table &&
@@ -76,7 +78,7 @@ const EntityListItem = ({ id, projectRef, item: entity, isLocked }: EntityListIt
const rows = await fetchAllTableRows({
projectRef,
- connectionString: project.connectionString,
+ connectionString: project?.connectionString,
table: supaTable,
})
const formattedRows = rows.map((row) => {
diff --git a/apps/studio/data/table-rows/table-rows-query.ts b/apps/studio/data/table-rows/table-rows-query.ts
index b8fabb6b642..2b3930b5434 100644
--- a/apps/studio/data/table-rows/table-rows-query.ts
+++ b/apps/studio/data/table-rows/table-rows-query.ts
@@ -11,6 +11,7 @@ import {
} from '../sql/execute-sql-query'
import { getPagination } from '../utils/pagination'
import { formatFilterValue } from './utils'
+import { IS_PLATFORM } from 'common'
type GetTableRowsArgs = {
table?: SupaTable
@@ -36,7 +37,7 @@ export const fetchAllTableRows = async ({
filters?: Filter[]
sorts?: Sort[]
}) => {
- if (!connectionString) {
+ if (IS_PLATFORM && !connectionString) {
console.error('Connection string is required')
return []
}