Skip to content

feat: SORT ON <field>[/D] TO <newtable> (#8) - #14

Merged
DDecoene merged 3 commits into
mainfrom
feat/8-sort-to
Jun 24, 2026
Merged

feat: SORT ON <field>[/D] TO <newtable> (#8)#14
DDecoene merged 3 commits into
mainfrom
feat/8-sort-to

Conversation

@DDecoene

Copy link
Copy Markdown
Owner

Closes #8.

What

Adds the dBASE III SORT command:

SORT ON <field>[/D] TO <newtable>
  • Writes a sorted copy of the active table into a new table.
  • /D → descending (default ascending).
  • Honours the active SET FILTER.
  • Errors when: no table in use, the field doesn't exist, or the target table already exists.

Approach — thin alias

After discussion, SORT is authentic dBASE III but largely redundant in WebBase-III's SQLite model (live indexes + ORDER BY already cover ordering). It's implemented thinly, over CREATE TABLE … AS SELECT … ORDER BY, rather than a faithful schema clone.

Accepted trade-off: the new table is a plain snapshot — column affinities are inferred and the source PK/constraints are not carried over. Noted in CHANGELOG. Spec: docs/superpowers/specs/2026-06-24-sort-to-design.md.

Changes

  • src/interpreter/Lexer.tsSORT keyword
  • src/interpreter/Parser.tsparseSort() + SORT AST node
  • src/interpreter/Executor.tsdoSort() + HELP line
  • tests/Session.test.ts — 2 parser + 5 integration tests
  • README.md, CLAUDE.md — command-table rows
  • package.json 0.6.2 → 0.6.3, CHANGELOG.md

Verification

  • npm test → 172 passed
  • npx tsc --noEmit → clean

🤖 Generated with Claude Code

DDecoene and others added 3 commits June 24, 2026 21:40
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Writes a sorted copy of the active table to a new table. /D sorts
descending; the active SET FILTER is honoured. Errors when no table is
in use, the field is unknown, or the target already exists.

Thin alias over SQLite's CREATE TABLE AS SELECT ... ORDER BY — the new
table is a plain snapshot (inferred affinities, no source PK/constraints).
SORT is largely redundant given live indexes + ORDER BY; it exists for
dBASE III dialect fidelity.

Bumps version to 0.6.3; adds parser + integration tests, HELP text, and
README/CLAUDE command-table rows.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@DDecoene
DDecoene merged commit f1fcdf9 into main Jun 24, 2026
1 check passed
@DDecoene
DDecoene deleted the feat/8-sort-to branch June 24, 2026 19:46
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.

SORT TO — physically sorted copy of a table

1 participant