Skip to content

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

escape single quotes when generating sql for fdw

Joshen Lime2e96cb0a66a
diff --git a/studio/components/interfaces/Database/Wrappers/Wrappers.tsx b/studio/components/interfaces/Database/Wrappers/Wrappers.tsx
index 5ae0b284e94..b761767a6db 100644
--- a/studio/components/interfaces/Database/Wrappers/Wrappers.tsx
+++ b/studio/components/interfaces/Database/Wrappers/Wrappers.tsx
@@ -204,7 +204,7 @@ const Wrappers = () => {
<Button
type="primary"
loading={isEnabling}
- disabled={isEnabling || !canToggleWrappers}
+ disabled={isNotAvailable || isEnabling || !canToggleWrappers}
onClick={() => onEnableWrappers()}
>
Enable Wrappers
diff --git a/studio/data/fdw/fdw-create-mutation.ts b/studio/data/fdw/fdw-create-mutation.ts
index f08e8b29054..c85e82941d4 100644
--- a/studio/data/fdw/fdw-create-mutation.ts
+++ b/studio/data/fdw/fdw-create-mutation.ts
@@ -34,7 +34,8 @@ export function getFDWCreateSql({
const createEncryptedKeysSqlArray = encryptedOptions.map((option) => {
const key = `${wrapper.name}_${option.name}`
- const value = formState[option.name] // TODO(alaister): escape '
+ // Escape single quotes in postgresql by doubling them up
+ const value = (formState[option.name] || '').replace(/'/g, "''")
return /* SQL */ `
select pgsodium.create_key(