Repository navigation
Add SQL execution and results to the frontend - #1499
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1487
The
--frontendpage can now run read-only SQL viaPOST /queryand show the result.Choices
/frontend.js(only with--frontend), so it is testable as a module. No framework, no build step.packages/rust/tests/frontend/query.test.mjs), run by the Rust integration testfrontend_js.rs. The request-ordering and rendering logic is injected (fetch, clock, a small fake document that throws oninnerHTML).{"sql": ...}that/querytakes. SQL is sent as written (the server trims it).SELECT * FROM './' LIMIT 100. Nothing runs on load or while typing; Run button or Ctrl/Cmd+Enter.role="alert".textContent; NULL is a marked cell; objects as JSON text; multiline kept viawhite-space: pre-wrap./querytakes JSON, so the test and script were corrected in the green push (the other 18 red tests are unchanged).Hand exercise (real server, headless Chrome via agent-browser)
dirsql server --frontend --port 7351in a dir witha.txt,b.html; page athttp://localhost:7351/.SELECT path, '<img src=x onerror=alert(1)>' AS h, NULL AS n, 'a\nb' AS m ...via Ctrl+Enter: img text shown literally,NULLcell, multiline value.WHERE 0: "0 rows returned in 17 ms. Column names are not available for an empty result."CREATE TABLE t (a): "Query error (HTTP 400): query() only accepts read-only statements; SQLite classified this statement as a write".SELECT FROM: "Query error (HTTP 400): SQLite error: near "FROM": syntax error".Speed-of-light proposal (not implemented)
Add a case to the existing server-query baseline (
packages/python/tests/e2e/server_speed_test.py): timePOST /queryfor the starter querySELECT * FROM './' LIMIT 100over a fixed fixture tree against the fastest native alternative, with the same ratio ratchet. That measures the path the page uses (server query plus JSON). Keep browser rendering out of it; if wanted, measure it separately withperformance.now()aroundrenderResultfor 100 and 1000 rows in a headless run.E2E Verification
cargo test --features cli --test cli_e2e --test frontend_js, plus router unit tests)packages/python/e2e-attestations/bot-1487-frontend-query-1011.jsonreceipt writtenpackages/ts/e2e-attestations/bot-1487-frontend-query-1011.jsonreceipt writtenmaturin develop --release;testing-conventions e2e attest 'uv run python -m pytest tests/e2e/cli_version_test.py tests/e2e/query_contract_test.py tests/e2e/fanout_test.py tests/e2e/extension_package_test.py tests/e2e/server_speed_test.py -x -q'(14 passed);testing-conventions e2e attest 'pnpm test:e2e'(18 passed); gatedjust preflight(0 failing).Changelog / Migrations
packages/rust/changelog.d/packages/rust/migrations.d/