Skip to content

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

prepend create view sql

Alaister Younge8542ea39d7f
diff --git a/studio/components/interfaces/TableGridEditor/TableDefinition.tsx b/studio/components/interfaces/TableGridEditor/TableDefinition.tsx
index a1f1033bc75..5b30e69adc2 100644
--- a/studio/components/interfaces/TableGridEditor/TableDefinition.tsx
+++ b/studio/components/interfaces/TableGridEditor/TableDefinition.tsx
@@ -52,10 +52,15 @@ const ViewDefinition = ({ id }: ViewDefinitionProps) => {
const { data: definition, isLoading } =
entityType?.type === ENTITY_TYPE.VIEW ? viewResult : tableResult
+ const prepend =
+ entityType?.type === ENTITY_TYPE.VIEW
+ ? `create view ${entityType.schema}.${entityType.name} as\n`
+ : ''
+
const formattedDefinition = useMemo(
() =>
definition
- ? format(definition, {
+ ? format(prepend + definition, {
language: 'postgresql',
keywordCase: 'lower',
})