Skip to content

fix(admin): show the privilege statements before running them - #558

Merged
EVWorth merged 1 commit into
mainfrom
fix/admin-privilege-preview
Sep 7, 2026
Merged

EVWorth merged 1 commit into
mainfrom
fix/admin-privilege-preview

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Closes #439.

Most of this was already done

Revokes are emitted before grants so an interruption leaves less access rather than more, privileges are batched per scope, a partial failure names the statement that failed and what had already applied, and the grants are re-read either way. What was missing is the half of the acceptance asking for a preview.

Apply Changes now shows the whole batch and runs nothing until Execute.

Why that matters more here than anywhere else

GRANT and REVOKE each force an implicit commit, so once the first statement runs there is no way back. Confirmed against MySQL 8:

START TRANSACTION;
GRANT SELECT ON test_db.* TO 'rbtest'@'%';
ROLLBACK;
SHOW GRANTS FOR 'rbtest'@'%';
-- GRANT SELECT ON `test_db`.* TO `rbtest`@`%`

So the transaction the issue proposes cannot work — the same shape as #379 and #394. The preview is the last point at which the change can still be reconsidered. The comment at the execution site already said this; the UI just didn't act on it.

Structure

SQLPreviewDialog moves from components/designer to components/common. It was already generic (sql, onClose, onExecute) and admin is its second caller.

Tests

Three, all failing against the previous version. One existing test now clicks through the preview, since that's the path.

Their assertions filter by connection id — components mounted by earlier tests in this file keep settling promises into the same mock, which made a first version of these tests fail against calls a different test had made. Worth knowing if you touch this file.

1806 unit + 303 browser, tsc/dprint/eslint clean.

Remaining in admin

🤖 Generated with Claude Code

Closes #439.

Most of this issue was already addressed: revokes are emitted before grants
so an interruption leaves less access rather than more, privileges are
batched per scope, a partial failure names the statement that failed and
what had already applied, and the grants are re-read either way. What was
missing is the half of its acceptance that asks for a preview.

Apply Changes now shows the whole batch and runs nothing until Execute.

That matters here more than anywhere else in the app. GRANT and REVOKE each
force an implicit commit, so once the first statement runs there is no way
back. Confirmed against MySQL 8:

    START TRANSACTION;
    GRANT SELECT ON test_db.* TO 'rbtest'@'%';
    ROLLBACK;
    SHOW GRANTS FOR 'rbtest'@'%';
    -> GRANT SELECT ON `test_db`.* TO `rbtest`@`%`

So the transaction the issue proposes cannot work, and the preview is the
last point at which the change can still be reconsidered. The comment at the
execution site already said as much; the UI did not act on it.

SQLPreviewDialog moves from components/designer to components/common. It was
already generic — sql, onClose, onExecute — and admin is its second caller.

Three tests, all failing against the previous version. One existing test now
clicks through the preview, since that is the path.

Their assertions filter by connection id: components mounted by earlier
tests in this file keep settling promises into the same mock, which made a
first version of these tests fail against calls another test had made.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit 827527c into main Sep 7, 2026
10 checks passed
@EVWorth
EVWorth deleted the fix/admin-privilege-preview branch September 7, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1] [bug] applyChanges runs statements as separate awaits — partial failure corrupts DB

1 participant