Skip to content

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

add support for views

Alaister Youngeb3e1c923273
diff --git a/studio/components/grid/SupabaseGrid.tsx b/studio/components/grid/SupabaseGrid.tsx
index 9e05fe65ab3..731050edf6d 100644
--- a/studio/components/grid/SupabaseGrid.tsx
+++ b/studio/components/grid/SupabaseGrid.tsx
@@ -6,11 +6,9 @@ import { useMonaco } from '@monaco-editor/react'
import { DataGridHandle } from '@supabase/react-data-grid'
import { useUrlState } from 'hooks'
-import { Dictionary, SupabaseGridProps, SupabaseGridRef, SupaTable } from './types'
+import { Dictionary, SupabaseGridProps, SupabaseGridRef } from './types'
import { useTableRowsQuery } from 'data/table-rows/table-rows-query'
import { StoreProvider, useDispatch, useTrackedState } from './store'
-import { fetchCount, fetchPage, refreshPageDebounced } from './utils'
-import { REFRESH_PAGE_IMMEDIATELY, TOTAL_ROWS_RESET } from './constants'
import { Shortcuts } from './components/common'
import { Grid } from './components/grid'
import Header from './components/header'
@@ -73,9 +71,7 @@ const SupabaseGridLayout = forwardRef<SupabaseGridRef, SupabaseGridProps>((props
const sorts = formatSortURLParams(sort as string[])
const filters = formatFilterURLParams(filter as string[])
- // [Joshen] This is not a perfect fix, but the useEffect to initialize the data in the editor
- // was not getting retriggered for views, works fine for tables.
- const table = (typeof props.table === 'string' ? { name: props.table } : props.table) as SupaTable // TODO(alaister): add support for views
+ const table = props.table
const { project } = useProjectContext()
const { data } = useTableRowsQuery(
@@ -119,21 +115,6 @@ const SupabaseGridLayout = forwardRef<SupabaseGridRef, SupabaseGridProps>((props
if (!mounted) setMounted(true)
}, [])
- // TODO(alaister): update this to react-query
- // useEffect(() => {
- // if (state.refreshPageFlag === REFRESH_PAGE_IMMEDIATELY) {
- // fetchPage(state, dispatch, sorts, filters)
- // } else if (state.refreshPageFlag !== 0) {
- // refreshPageDebounced(state, dispatch, sorts, filters)
- // }
- // }, [state.refreshPageFlag])
-
- // useEffect(() => {
- // if (state.totalRows === TOTAL_ROWS_RESET) {
- // fetchCount(state, dispatch, filters)
- // }
- // }, [state.totalRows])
-
useEffect(() => {
if (mounted) {
dispatch({ type: 'UPDATE_FILTERS', payload: {} })
diff --git a/studio/components/grid/types/grid.ts b/studio/components/grid/types/grid.ts
index 8f10889e74a..4424a2d5127 100644
--- a/studio/components/grid/types/grid.ts
+++ b/studio/components/grid/types/grid.ts
@@ -15,7 +15,7 @@ export interface SupabaseGridProps {
/**
* database table swagger or table name
*/
- table: SupaTable | string
+ table: SupaTable
/**
*
* run sql query
diff --git a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
index f26ea1a6dec..d3fc849bdf0 100644
--- a/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
+++ b/studio/components/interfaces/TableGridEditor/TableGridEditor.tsx
@@ -112,7 +112,12 @@ const TableGridEditor: FC<Props> = ({
},
encryptedColumns
)
- : (selectedTable as SchemaView).name
+ : parseSupaTable({
+ table: selectedTable as SchemaView,
+ columns: (selectedTable as SchemaView).columns ?? [],
+ primaryKeys: [],
+ relationships: [],
+ })
const gridKey = `${selectedTable.schema}_${selectedTable.name}`