Skip to content

Commit 61ccc28

Browse files
authored
fix: Add handling for single quotes in option values when creating FDW. (supabase#37635)
Add handling for single quotes in option values when creating FDW.
1 parent 6e99ca6 commit 61ccc28

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

apps/studio/data/fdw/fdw-create-mutation.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,9 @@ export function getCreateFDWSql({
118118
.map((option) => `${option.name} ''%s''`)
119119
const unencryptedOptionsSqlArray = unencryptedOptions
120120
.filter((option) => formState[option.name])
121-
// wrap all options in double quotes, some option names have dots in them
122-
.map((option) => `"${option.name}" ''${formState[option.name]}''`)
121+
// wrap all option names in double quotes to handle dots
122+
// wrap all options values in single quotes, replace single quotes with 4 single quotes to escape them in SQL past the execute format
123+
.map((option) => `"${option.name}" ''${formState[option.name].replace(/'/g, `''''`)}''`)
123124
const optionsSqlArray = [...encryptedOptionsSqlArray, ...unencryptedOptionsSqlArray].join(',')
124125

125126
const createServerSql = /* SQL */ `

0 commit comments

Comments
 (0)