Skip to content

Commit 24627e1

Browse files
authored
Swap check for using in insert commands (supabase#22260)
* Swap check for using in insert commands * Cleanup
1 parent 65a4408 commit 24627e1

File tree

1 file changed

+7
-2
lines changed
  • apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel

1 file changed

+7
-2
lines changed

apps/studio/components/interfaces/Auth/Policies/AIPolicyEditorPanel/index.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,13 @@ export const AIPolicyEditorPanel = memo(function ({
306306

307307
const onSubmit = (data: z.infer<typeof FormSchema>) => {
308308
const { name, table, behavior, command, roles } = data
309-
const using = editorOneRef.current?.getValue().trim() ?? undefined
310-
const check = editorTwoRef.current?.getValue().trim() ?? undefined
309+
let using = editorOneRef.current?.getValue().trim() ?? undefined
310+
let check = editorTwoRef.current?.getValue().trim()
311+
312+
// [Terry] b/c editorOneRef will be the check statement in this scenario
313+
if (command === 'insert') {
314+
check = using
315+
}
311316

312317
if (command === 'insert' && (check === undefined || check.length === 0)) {
313318
return setFieldError('Please provide a SQL expression for the WITH CHECK statement')

0 commit comments

Comments
 (0)