Files
supabase/packages/pg-meta/test/sql/studio/table-definition.test.ts
Andrew ValleteauandClaude Opus 5.5 e42f4ec612 chore: remove pgMetaScopedIntrospection feature flag (#52019)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Cleanup: remove a fully rolled-out Studio feature flag. Resolves
CLI-2759. Supersedes #50260 and #47931 (rebuilt on current master).

## What is the new behavior?

Scoped introspection is the only path.

- Studio: delete `data/scoped-introspection.ts` and
`PG_META_SCOPED_INTROSPECTION_FLAG`; stop threading `scoped` through
table editor, rows/counts, privileges, enumerated types, table
definition, retrieve, prefetcher, `EntityListItem`, `SidePanelEditor`,
`EditHookPanel`, `DefaultLayout`.
- pg-meta: drop `scoped?: boolean` from public builders and delete the
frozen unscoped SQL. `tables.list` keeps its full-catalog `TABLES_SQL`
(never flag-gated).

## Test plan

- [x] pg-meta + Studio typecheck
- [x] pg-meta suite against Docker DB (521/521)
- [x] Studio vitest for touched areas
- [x] Open Table Editor, row counts, privileges, and enumerated types on
a project (dogfooded on the preview deploy)
- [ ] After merge, retire `pgMetaScopedIntrospection` in the flag
dashboard

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 17:40:13 +02:00

68 lines
2.2 KiB
TypeScript

import { afterAll, expect, test } from 'vitest'
import { getTableDefinitionSql } from '../../../src'
import { cleanupRoot, createTestDatabase } from '../../db/utils'
afterAll(async () => {
await cleanupRoot()
})
test('getTableDefinitionSql: escapes double quotes in schema, table, column and constraint names', async () => {
const db = await createTestDatabase()
try {
await db.executeQuery(`
create schema "pub""lic2";
create table "pub""lic2"."te""st" (
id bigint generated by default as identity,
"we""ird" text not null,
constraint "pk""test" primary key (id)
);
`)
const [{ id }] = await db.executeQuery<{ id: number }[]>(
`select '"pub""lic2"."te""st"'::regclass::oid::int8 as id;`
)
const sql = getTableDefinitionSql({ id })
const [{ definition }] = await db.executeQuery<{ definition: string }[]>(sql)
expect(definition).toContain('"pub""lic2"')
expect(definition).toContain('"te""st"')
expect(definition).toContain('"we""ird"')
expect(definition).toContain('"pk""test"')
// the generated DDL must itself be valid, executable SQL
await db.executeQuery(`drop table "pub""lic2"."te""st";`)
await db.executeQuery(definition)
} finally {
await db.cleanup()
}
})
test('getTableDefinitionSql: quotes the parent schema for an inherited table', async () => {
const db = await createTestDatabase()
try {
await db.executeQuery(`
create schema "par""ent1";
create table "par""ent1"."par""ent_tbl" (id bigint primary key);
create schema "chi""ld1";
create table "chi""ld1"."chi""ld_tbl" () inherits ("par""ent1"."par""ent_tbl");
`)
const [{ id }] = await db.executeQuery<{ id: number }[]>(
`select '"chi""ld1"."chi""ld_tbl"'::regclass::oid::int8 as id;`
)
const sql = getTableDefinitionSql({ id })
const [{ definition }] = await db.executeQuery<{ definition: string }[]>(sql)
expect(definition).toContain('INHERITS ("par""ent1"."par""ent_tbl")')
// the generated DDL must itself be valid, executable SQL
await db.executeQuery(`drop table "chi""ld1"."chi""ld_tbl";`)
await db.executeQuery(definition)
} finally {
await db.cleanup()
}
})