You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make Explain use the statement at the cursor, like Ctrl+Enter #846
On http://localhost:1420/?mock=connected:
Enter SELECT * FROM products; and SELECT * FROM orders; on two lines and put the cursor on line 1.
Ctrl+Enter runs only line 1, as expected.
Click Explain, or press Ctrl+Shift+E. The pane shows "Query Error — Error: Query error: EXPLAIN supports a single statement — 2 were given. Select one statement and re-run."
Click the toolbar Run button. Both statements run ("Result 1 / Result 2" tabs appear), although the hint beside the button reads "Ctrl+Enter / F9", and Ctrl+Enter runs only the current statement.
Cause
src/components/editor/SQLEditor.tsx:212-233 (Explain) and :236-257 (Explain Analyze) use model.getValue() when there is no selection.
src/components/editor/QueryToolbar.tsx:85-96 (getCurrentSql, used by Run, Explain and Explain Analyze) also returns the whole model.
Only the Ctrl+Enter action (SQLEditor.tsx:153-172) uses getStatementAtCursor.
Fix
Use getStatementAtCursor in all of these paths. Alternatively, if the toolbar Run button should run everything, label it "Run all (Ctrl+Shift+Enter)".
Activity
fix(editor): explain the statement at the cursor
test: give the browser test's editor a cursor
release: 1.4.0 (#871)