AI error fix in place
functionalWhen AI explains a failed statement, replace the broken statement with its fix in one undoable edit.
When a query fails, Explain Last Error (AI) in the command palette opens the AI drawer seeded with the error, the statement that failed, and the script it ran in. The prompt asks for only the corrected failing statement back. When the answer includes corrected SQL, you do not have to copy it back by hand: next to Insert and New query the answer offers Replace failing statement.
What gets replaced
SQLly finds the statement that failed - not just wherever the caret happens to be - and
swaps it for the AI's version. The conversation remembers which tab and which run the error
came from when you started it, so a later failure in another tab, or a successful run
elsewhere, does not change where the fix goes. It locates the run in that tab (the recorded
run region, or the run's text if you have edited above it since), then narrows to the one
failing statement using the position the engine reported: the line number for SQL Server
and MySQL (respecting GO batches), the character position for PostgreSQL. A
comment directly above the statement stays where it is. The new text is selected so you
can see exactly what changed.
If the answer repeats the rest of the script anyway, pasting it over one statement would duplicate everything around it, so SQLly replaces the whole run instead and says so in the status bar. The button appears on the answers to the error question only: asking a follow-up, starting a new chat, or applying the fix once turns it off.
- Run a script; one statement fails.
- Choose Explain Last Error (AI).
- Read the explanation, then click Replace failing statement on the fixed SQL.
- Run again. If the fix is wrong, Cmd/Ctrl+Z brings the original statement back in one step.
