mirror of
https://github.com/supabase/supabase.git
synced 2026-05-09 18:30:12 -04:00
62d59d596b
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved SQL construction across the studio to make queries safer and more consistent. * Safer parameter handling for optional schema and remediation links to prevent injection risks. * Deterministic query header formatting and stable date/comments in generated SQL. * More robust user-count and paginated-user queries for accurate counts, sorting and pagination. * Updated tests to align with the new safe query handling. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
28 lines
992 B
TypeScript
28 lines
992 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { enrichLintsQuery, safeSql } from '../../../src'
|
|
|
|
describe('enrichLintsQuery', () => {
|
|
const dummyQuery = safeSql`SELECT 1`
|
|
|
|
it('should include SET LOCAL pgrst.db_schemas when exposedSchemas is provided', () => {
|
|
const result = enrichLintsQuery(dummyQuery, 'public, storage')
|
|
expect(result).toContain("set local pgrst.db_schemas = 'public, storage';")
|
|
})
|
|
|
|
it('should NOT include SET LOCAL pgrst.db_schemas when exposedSchemas is undefined', () => {
|
|
const result = enrichLintsQuery(dummyQuery, undefined)
|
|
expect(result).not.toContain('pgrst.db_schemas')
|
|
})
|
|
|
|
it('should NOT include SET LOCAL pgrst.db_schemas when exposedSchemas is empty string', () => {
|
|
const result = enrichLintsQuery(dummyQuery, '')
|
|
expect(result).not.toContain('pgrst.db_schemas')
|
|
})
|
|
|
|
it('should always include the query', () => {
|
|
const result = enrichLintsQuery(dummyQuery)
|
|
expect(result).toContain(dummyQuery)
|
|
})
|
|
})
|