mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Context We previously added a "Related resources" section in Cmd+K if you're on the Table Editor with a table opened, this included resources pertaining to the table such as policies, triggers, and functions. We're adding indexes as well in this PR - thinking that might also be appropriate to have in this context <img width="500" alt="image" src="https://github.com/user-attachments/assets/5cd383ff-6617-49ba-bdb8-6f65d8fd0680" /> ## Performance Benchmarked with Claude against the stress catalog (`PG_META_STRESS_TABLES=12000`), with master and this branch timed in the same run on the same database, median of 9. | Table | master | This PR | Worst of 9 | |---|---|---|---| | Hub table — 8 indexes, policy, many FK triggers | 1.6 ms | 2.3 ms | 2.8 ms | | Policy + user trigger | 1.0 ms | 1.3 ms | 2.0 ms | | Mid-chain table | 1.1 ms | 1.5 ms | 1.7 ms | | Deliberately over-indexed table — 20 indexes | 0.8 ms | 2.0 ms | 4.6 ms | | Table that doesn't exist | 1.1 ms | 1.5 ms | 4.5 ms |
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
getIndexEditorRoute,
|
|
getPolicyEditorRoute,
|
|
getTableEditorRoute,
|
|
getTriggerEditorRoute,
|
|
} from './DatabaseEntityRoutes.utils'
|
|
|
|
// The policy, trigger, function and index routes are built by one shared
|
|
// helper, so the query string is covered once here. The cases below only cover
|
|
// where a route genuinely departs from it.
|
|
describe('the shared schema and edit query string', () => {
|
|
it('encodes the schema, which is free text', () => {
|
|
expect(getPolicyEditorRoute('abc', { id: 7, schema: 'my schema&x' })).toBe(
|
|
'/project/abc/database/policies?schema=my%20schema%26x&edit=7'
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('getTriggerEditorRoute', () => {
|
|
it('links to the list page directly, since the index route drops the query string', () => {
|
|
expect(getTriggerEditorRoute('abc', { id: 5, schema: 'public' })).toBe(
|
|
'/project/abc/database/triggers/data?schema=public&edit=5'
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('getIndexEditorRoute', () => {
|
|
it('matches the index by name, encoded, rather than by id', () => {
|
|
expect(getIndexEditorRoute('abc', { name: 'idx posts&author', schema: 'public' })).toBe(
|
|
'/project/abc/database/indexes?schema=public&edit=idx%20posts%26author'
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('getTableEditorRoute', () => {
|
|
it('puts the table id in the path rather than an edit param', () => {
|
|
expect(getTableEditorRoute('abc', { id: 42, schema: 'my schema' })).toBe(
|
|
'/project/abc/editor/42?schema=my%20schema'
|
|
)
|
|
})
|
|
})
|