Skip to content

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

fix: editing RLS policies (#22228)

Alaister Young27a8b89526db
diff --git a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/PolicyDetailsV2.tsx b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/PolicyDetailsV2.tsx
index 281aa5e0706..8840292fd1c 100644
--- a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/PolicyDetailsV2.tsx
+++ b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/PolicyDetailsV2.tsx
@@ -55,8 +55,8 @@ export const PolicyDetailsV2 = ({ isEditing, form, onUpdateCommand }: PolicyDeta
.sort((a, b) => a.name.localeCompare(b.name))
useEffect(() => {
- if (isSuccessTables && tables.length > 0) form.setValue('table', tables[0].name)
- }, [isSuccessTables, tables])
+ if (!isEditing && isSuccessTables && tables.length > 0) form.setValue('table', tables[0].name)
+ }, [isEditing, isSuccessTables, tables])
return (
<>
diff --git a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx
index b89b0f0b9aa..d2add7ffccb 100644
--- a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx
+++ b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx
@@ -351,7 +351,13 @@ export const AIPolicyEditorPanel = memo(function ({
if (!isEqual(selectedPolicy.roles, updatedRoles)) payload.roles = updatedRoles
if (selectedPolicy.definition !== null && selectedPolicy.definition !== using)
payload.definition = using
- if (selectedPolicy.check !== null && selectedPolicy.check !== check) payload.check = check
+
+ if (selectedPolicy.command === 'INSERT') {
+ // [Joshen] Cause editorOneRef will be the check statement in this scenario
+ if (selectedPolicy.check !== null && selectedPolicy.check !== using) payload.check = using
+ } else {
+ if (selectedPolicy.check !== null && selectedPolicy.check !== check) payload.check = check
+ }
if (Object.keys(payload).length === 0) return onSelectCancel()