Skip to content

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

fix(pg-meta): set pgrst.db_schemas to '' when the Data API is off (#52162)

Charis592365408eb4
diff --git a/packages/pg-meta/src/sql/studio/advisor/lints.ts b/packages/pg-meta/src/sql/studio/advisor/lints.ts
index e5309f7271f..3ee9d24e117 100644
--- a/packages/pg-meta/src/sql/studio/advisor/lints.ts
+++ b/packages/pg-meta/src/sql/studio/advisor/lints.ts
@@ -9,7 +9,7 @@ exception when others then
-- not a superuser or extension not installed, skip silently
end
$$;
-${!!exposedSchemas ? safeSql`set local pgrst.db_schemas = ${literal(exposedSchemas)};` : safeSql``}
+${exposedSchemas !== undefined ? safeSql`set local pgrst.db_schemas = ${literal(exposedSchemas)};` : safeSql``}
-- source: dashboard
-- user: self host
-- date: ${new Date().toISOString() as SafeSqlFragment}
diff --git a/packages/pg-meta/test/sql/studio/lints.test.ts b/packages/pg-meta/test/sql/studio/lints.test.ts
index d5eee906fa4..b39a4e4fb9e 100644
--- a/packages/pg-meta/test/sql/studio/lints.test.ts
+++ b/packages/pg-meta/test/sql/studio/lints.test.ts
@@ -15,9 +15,9 @@ describe('enrichLintsQuery', () => {
expect(result).not.toContain('pgrst.db_schemas')
})
- it('should NOT include SET LOCAL pgrst.db_schemas when exposedSchemas is empty string', () => {
+ it("should set pgrst.db_schemas to '' when exposedSchemas is empty string (Data API off)", () => {
const result = enrichLintsQuery(dummyQuery, '')
- expect(result).not.toContain('pgrst.db_schemas')
+ expect(result).toContain("set local pgrst.db_schemas = '';")
})
it('should always include the query', () => {