Public: anyone can read this; the crew can change it.

A `.sql` file in a repository opens as its schema: each CREATE TABLE as its columns, other statements one per row #11196

Closed opened this
Closed without merging

A .sql file now opens as one block per statement, with the raw source still one tap away. I did not call keepplan, so the plan on the issue was never updated. tsc, scripts/gate.ts, design-lint and 248 render/file tests pass.

Notes

stopped closed without shipping deploy 7f9502e

opened this

A .sql file now opens as one block per statement, with the raw source still one tap away. I did not call keep_plan, so the plan on the issue was never updated. tsc, scripts/gate.ts, design-lint and 248 render/file tests pass. I did not run the full suite or open a file in a running app.

What changed

  • Parser: the new src/web/render/sql.ts is plain TypeScript with no dependency. It splits statements outside quotes, comments and parentheses.
  • CREATE TABLE: it shows an h3 with the table name and a dense .table with a row per column (name, type, NOT NULL, PRIMARY KEY, DEFAULT). A table-level PRIMARY KEY (a, b) marks those columns, and the other table-level constraints are listed under the table.
  • Other statements: each is one row with its first line.
  • Fallback: a file with no recognisable SQL, or an unterminated quote or comment, shows the plain source with a reason instead of an error. A CREATE TABLE it can't parse becomes one ordinary row.
  • Escaping and cap: every name is escaped by the template. The file size cap is 1 MB, and at most 500 statements and 500 columns per table are drawn, then "N more not shown".
  • Wiring: sql is added as a kind in kinds.ts and renderers.ts. Only the .sql extension reaches it, so other kinds are unaffected.
  • Docs and tests:
    • test/render-sql.test.ts covers constraints, comments, a quoted name containing <, an unparsable file, malformed tables and the cap.
    • test/render-kinds.test.ts gets a one-line .sql sample entry.
    • docs/features/file-sql.md says what a reader sees, and docs/design/areas/render.md gets a short section.

Chose not to do

  • There is no dollar-quoted ($$) body handling or dialect-specific parsing; unusual syntax falls to the one-row form.
  • There is no terminal (TUI) view, which the env renderer has.

Push note: the pre-push hook wanted a Try: commit, so there's an empty one at the end of the branch.

Try it: open any db/*.sql or migration file in a repository. Add ?view=source to see the raw text.

🤖 Generated with Claude Code

Closes #11187

commented

A .sql file now opens as one block per statement, with the raw source still one tap away. I did not call keep_plan, so the plan on the issue was never updated. tsc, scripts/gate.ts, design-lint and 248 render/file tests pass. I did not run the full suite or open a file in a running app.

What changed

  • Parser: the new src/web/render/sql.ts is plain TypeScript with no dependency. It splits statements outside quotes, comments and parentheses.
  • CREATE TABLE: it shows an h3 with the table name and a dense .table with a row per column (name, type, NOT NULL, PRIMARY KEY, DEFAULT). A table-level PRIMARY KEY (a, b) marks those columns, and the other table-level constraints are listed under the table.
  • Other statements: each is one row with its first line.
  • Fallback: a file with no recognisable SQL, or an unterminated quote or comment, shows the plain source with a reason instead of an error. A CREATE TABLE it can't parse becomes one ordinary row.
  • Escaping and cap: every name is escaped by the template. The file size cap is 1 MB, and at most 500 statements and 500 columns per table are drawn, then "N more not shown".
  • Wiring: sql is added as a kind in kinds.ts and renderers.ts. Only the .sql extension reaches it, so other kinds are unaffected.
  • Docs and tests:
    • test/render-sql.test.ts covers constraints, comments, a quoted name containing <, an unparsable file, malformed tables and the cap.
    • test/render-kinds.test.ts gets a one-line .sql sample entry.
    • docs/features/file-sql.md says what a reader sees, and docs/design/areas/render.md gets a short section.

Chose not to do

  • There is no dollar-quoted ($$) body handling or dialect-specific parsing; unusual syntax falls to the one-row form.
  • There is no terminal (TUI) view, which the env renderer has.

Push note: the pre-push hook wanted a Try: commit, so there's an empty one at the end of the branch.

Try it: open any db/*.sql or migration file in a repository. Add ?view=source to see the raw text.

🤖 Generated with Claude Code

commented

Declined: the preview deploy did not fail. The log ends done: https://lab--11196--forge-trevato-apps.open-platform.sh, the process was up in 4.2 s, and / on the preview answers 200. "No tests declared, none run" is a note, not an error. It is there because forge.json has no test command; the tests run through check, which the forge runs on each push. There is nothing in the pull to fix. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m745q54hpjqkgewq1hk0j829

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs