The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Some problems with RLS editor (#45662)
Joshen Lime6b81c465a47
diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/LockedQuerySection.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/LockedQuerySection.tsxindex 83c3ef7fcbd..6f5d5aa5a0b 100644--- a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/LockedQuerySection.tsx+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/LockedQuerySection.tsx@@ -4,11 +4,13 @@ import { Lock } from 'lucide-react'interface LockedCreateQuerySection {schema: stringselectedPolicy?: PostgresPolicy+ isRenamingPolicy: booleanformFields: { name: string; table: string; behavior: string; command: string; roles: string }}export const LockedCreateQuerySection = ({schema,+ isRenamingPolicy,selectedPolicy,formFields,}: LockedCreateQuerySection) => {@@ -31,7 +33,7 @@ export const LockedCreateQuerySection = ({<p className="px-6 font-mono text-sm text-foreground-light select-none">1</p><p className="font-mono tracking-tighter"><span className="text-[#569cd6]">{isEditing ? 'alter' : 'create'}</span> policy "- {name.length === 0 ? 'policy_name' : name}"+ {isRenamingPolicy ? selectedPolicy?.name : name.length === 0 ? 'policy_name' : name}"</p></div><div className="flex items-start" style={{ fontSize: '14px' }}>diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyTemplates.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyTemplates.tsxindex d1377074e90..b5f7afb781e 100644--- a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyTemplates.tsx+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/PolicyTemplates.tsx@@ -105,7 +105,7 @@ export const PolicyTemplates = ({className={cn('rounded-sm! font-mono',template.command === 'UPDATE'- ? 'bg-blue-400 text-blue-900 border border-blue-800'+ ? 'bg-blue-900/50 text-blue-200 border border-blue-800': '')}variant={diff --git a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/index.tsx b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/index.tsxindex cedfe7f4d6c..9ebe0d7cf16 100644--- a/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/index.tsx+++ b/apps/studio/components/interfaces/Auth/Policies/PolicyEditorPanel/index.tsx@@ -80,6 +80,8 @@ const defaultValues = {/*** Using memo for this component because everything rerenders on window focus because of outside fetches+ * Note: For INSERT command, editor one holds the check expression (not using)+ Whereas for others: editor one = using, editor two = optional check*/export const PolicyEditorPanel = memo(function ({visible,@@ -184,8 +186,7 @@ export const PolicyEditorPanel = memo(function ({const onSubmit = (data: z.infer<typeof FormSchema>) => {const { name, table, behavior, command, roles } = data- // For INSERT: editor one holds the check expression (not using)- // For others: editor one = using, editor two = optional check+ // [Joshen] Refer to top note as to why we're using the "USING" section for INSERTconst usingExpr = command !== 'insert' ? using : undefinedconst checkExpr = command === 'insert' ? using : check@@ -280,14 +281,16 @@ export const PolicyEditorPanel = memo(function ({command: command.toLowerCase(),roles: roles.length === 1 && roles[0] === 'public' ? '' : roles.join(', '),})- if (selectedPolicy.definition) setUsing(safeSql` ${selectedPolicy.definition}`)- if (selectedPolicy.check && selectedPolicy.command === 'INSERT')- setUsing(safeSql` ${selectedPolicy.check}`)- if (selectedPolicy.check && selectedPolicy.command !== 'INSERT')- setCheck(safeSql` ${selectedPolicy.check}`)- if (selectedPolicy.check && selectedPolicy.command !== 'INSERT') {- setShowCheckBlock(true)++ // [Joshen] Refer to top note as to why we're using the "USING" section for INSERT+ if (selectedPolicy.definition) {+ setUsing(safeSql` ${selectedPolicy.definition}`)+ }+ if (selectedPolicy.check) {+ if (selectedPolicy.command === 'INSERT') setUsing(safeSql` ${selectedPolicy.check}`)+ else setCheck(safeSql` ${selectedPolicy.check}`)}+setRolesFragment(roles.length === 1 && roles[0] === 'public'? safeSql`public`@@ -356,6 +359,7 @@ export const PolicyEditorPanel = memo(function ({<LockedCreateQuerySectionschema={schema}selectedPolicy={selectedPolicy}+ isRenamingPolicy={isRenamingPolicy}formFields={{ name, table, behavior, command, roles }}/>@@ -578,7 +582,16 @@ export const PolicyEditorPanel = memo(function ({form.setValue('roles', value.roles.join(', ') ?? '')setUsing(safeSql` ${value.definition}`)- setCheck(safeSql` ${value.check}`)++ // [Joshen] Refer to top note as to why we're using the "USING" section for INSERT+ if (value.check) {+ if (value.command === 'INSERT') {+ setUsing(safeSql` ${value.check}`)+ } else {+ setCheck(safeSql` ${value.check}`)+ }+ }+setRolesFragment(value.roles.length === 0 ||(value.roles.length === 1 && value.roles[0] === 'public')