The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
fix: empty search_path (#48151)
Vaibhav2e12cdc2e188
diff --git a/packages/pg-meta/src/pg-meta-functions.ts b/packages/pg-meta/src/pg-meta-functions.tsindex 45054a18dc8..473dd066d4f 100644--- a/packages/pg-meta/src/pg-meta-functions.ts+++ b/packages/pg-meta/src/pg-meta-functions.ts@@ -260,7 +260,7 @@ function _generateCreateFunctionSql(Object.entries(config_params).map(([param, value]) =>value === 'FROM CURRENT'? safeSql`SET ${qualifiedIdent(param)} FROM CURRENT`- : safeSql`SET ${qualifiedIdent(param)} TO ${value}`+ : safeSql`SET ${qualifiedIdent(param)} TO ${value === '""' ? literal('') : value}`),'\n')diff --git a/packages/pg-meta/test/functions.test.ts b/packages/pg-meta/test/functions.test.tsindex bc7c38d892f..2d5120534e5 100644--- a/packages/pg-meta/test/functions.test.ts+++ b/packages/pg-meta/test/functions.test.ts@@ -349,6 +349,38 @@ withTestDatabase('create function with various config_params values', async ({ eawait executeQuery(removeSql1)})+withTestDatabase('update function with empty string search_path', async ({ executeQuery }) => {+ const { sql: createSql } = pgMeta.functions.create({+ name: 'test_func_empty_search_path',+ schema: 'public',+ definition: 'select 1',+ return_type: safeSql`integer`,+ language: 'sql',+ config_params: { search_path: safeSql`''` },+ })+ await executeQuery(createSql)++ const { sql: retrieveSql, zod: retrieveZod } = pgMeta.functions.retrieve({+ name: 'test_func_empty_search_path',+ schema: 'public',+ args: [],+ })+ const result = retrieveZod.parse((await executeQuery(retrieveSql))[0])+ expect(result!.config_params).toEqual({ search_path: '""' })++ const { sql: updateSql } = pgMeta.functions.update(asSavedFunction(result!), {+ definition: 'select 2',+ })+ await executeQuery(updateSql)++ const resultUpdated = retrieveZod.parse((await executeQuery(retrieveSql))[0])+ expect(resultUpdated!.definition).toBe('select 2')+ expect(resultUpdated!.config_params).toEqual({ search_path: '""' })++ const { sql: removeSql } = pgMeta.functions.remove(asSavedFunction(resultUpdated!))+ await executeQuery(removeSql)+})+withTestDatabase('create function with namespaced custom GUC config_params',async ({ executeQuery }) => {