Skip to content

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

Swap check for using in insert commands (#22260)

Terry Sutton24627e1ed385
diff --git a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx
index d2add7ffccb..d05e7d47865 100644
--- a/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx
+++ b/apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx
@@ -306,8 +306,13 @@ export const AIPolicyEditorPanel = memo(function ({
const onSubmit = (data: z.infer<typeof FormSchema>) => {
const { name, table, behavior, command, roles } = data
- const using = editorOneRef.current?.getValue().trim() ?? undefined
- const check = editorTwoRef.current?.getValue().trim() ?? undefined
+ let using = editorOneRef.current?.getValue().trim() ?? undefined
+ let check = editorTwoRef.current?.getValue().trim()
+
+ // [Terry] b/c editorOneRef will be the check statement in this scenario
+ if (command === 'insert') {
+ check = using
+ }
if (command === 'insert' && (check === undefined || check.length === 0)) {
return setFieldError('Please provide a SQL expression for the WITH CHECK statement')