mirror of
https://github.com/supabase/supabase.git
synced 2026-09-06 09:59:03 +08:00
Removes the SQL Editor Pretty Explain feature — the Explain tab, the Run EXPLAIN ANALYZE action + shortcut, and its dead plumbing. It's been gated off behind the `DisablePrettyExplainOnSqlEditor` kill switch for weeks with no usage or complaints. `ExplainVisualizer` / `isExplainQuery` are kept — they're used independently by Query Insights, Query Performance, and the EditorPanel quick-runner. Manually-run `EXPLAIN` queries still render as raw rows in the Results tab. Typecheck, lint, and all affected unit tests pass. Closes FE-3930 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Changes** * Removed the SQL editor’s EXPLAIN execution workflow, including its toolbar action, keyboard shortcut, utility tab, and visual query-plan display. * Simplified query execution to focus on standard results and charts. * Improved result clearing when switching databases and refined execution error handling. * Updated SQL editor state and tests to reflect the streamlined experience. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
63 lines
2.0 KiB
TypeScript
63 lines
2.0 KiB
TypeScript
import { snapshot } from 'valtio'
|
|
import { beforeEach, describe, expect, it } from 'vitest'
|
|
|
|
import { sqlEditorSessionState } from './sql-editor-session-state'
|
|
|
|
// The session store is a module singleton, so reset its mutable fields before
|
|
// each test to keep cases independent.
|
|
beforeEach(() => {
|
|
sqlEditorSessionState.results = {}
|
|
sqlEditorSessionState.limit = 100
|
|
})
|
|
|
|
describe('sqlEditorSessionState', () => {
|
|
describe('results', () => {
|
|
it('addResult stores rows (and optional autoLimit) keyed by snippet id', () => {
|
|
sqlEditorSessionState.addResult('a', [{ x: 1 }], 50)
|
|
|
|
const result = sqlEditorSessionState.results['a']?.[0]
|
|
expect(result?.rows).toEqual([{ x: 1 }])
|
|
expect(result?.autoLimit).toBe(50)
|
|
expect(result?.error).toBeUndefined()
|
|
})
|
|
|
|
it('addResultError stores the error with empty rows', () => {
|
|
sqlEditorSessionState.addResultError('a', { message: 'boom' }, 25)
|
|
|
|
const result = sqlEditorSessionState.results['a']?.[0]
|
|
expect(result?.rows).toEqual([])
|
|
expect(result?.error).toEqual({ message: 'boom' })
|
|
expect(result?.autoLimit).toBe(25)
|
|
})
|
|
|
|
it('resetResult clears the rows for a snippet', () => {
|
|
sqlEditorSessionState.addResult('a', [{ x: 1 }])
|
|
sqlEditorSessionState.resetResult('a')
|
|
|
|
expect(sqlEditorSessionState.results['a']).toEqual([])
|
|
})
|
|
})
|
|
|
|
describe('clearForSnippet', () => {
|
|
it('deletes results for a snippet, leaving others intact', () => {
|
|
sqlEditorSessionState.addResult('a', [{ x: 1 }])
|
|
sqlEditorSessionState.addResult('b', [{ y: 2 }])
|
|
|
|
sqlEditorSessionState.clearForSnippet('a')
|
|
|
|
expect(sqlEditorSessionState.results['a']).toBeUndefined()
|
|
expect(sqlEditorSessionState.results['b']?.[0]?.rows).toEqual([{ y: 2 }])
|
|
})
|
|
})
|
|
|
|
describe('limit', () => {
|
|
it('defaults to 100 and is updated by setLimit', () => {
|
|
expect(snapshot(sqlEditorSessionState).limit).toBe(100)
|
|
|
|
sqlEditorSessionState.setLimit(500)
|
|
|
|
expect(snapshot(sqlEditorSessionState).limit).toBe(500)
|
|
})
|
|
})
|
|
})
|