Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
3.0 KiB
id, title, kind, expected_rounds
| id | title | kind | expected_rounds |
|---|---|---|---|
| feature-query | Implement the where query language of minidb from its specification | feature | 20-45 |
Implement the where query language of minidb from its specification
Seed: package minidb/ (9 modules, about 640 lines), SPEC.md (180 lines, the precise language definition), README.md, and 55 visible unittest tests
(all pass on the seed). The agent must create minidb/query.py (recursive-descent parser with three-valued logic), wire it into Table.select/update/delete/count
through the single Table._matcher choke point, add --where to the CLI (select; update and delete with --id/--where mutually exclusive), write
tests/test_query.py with at least 25 test methods, and document the feature in README.md.
Reference solution (reference/overlay/): minidb/query.py (387 lines), small edits to table.py and cli.py, README section, tests/test_query.py (31 tests).
Acceptance (accept.py):
- the pristine
tests/files andSPEC.mdare byte-identical; - the pristine visible tests pass (run from a clean copy of
tests/); hidden/test_hidden_spec.pypasses: 32 test methods, about 250 table-driven cases (select results, syntax error positions, name errors, type errors, short-circuit rules,Table/CLI integration). Every case is determined bySPEC.mdalone;tests/test_query.pyexists, has at least 25 test methods that contain an assertion call, mentionsminidbandwhere, and passes (at least 25 tests run);README.mdmentions--where.
Prompt
This repository is minidb, a small table store with a command line tool (see README.md). Table.select, Table.update, Table.delete and Table.count currently take a Python callable as where. SPEC.md defines a textual where query language for them, but nothing implements it yet. Please implement it:
- Create
minidb/query.pythat implementsSPEC.mdexactly, includingcompile_where(text, columns)and the exception classes that the spec names. - Make
Table.select,Table.update,Table.deleteandTable.countaccept a query string aswhere. Callables andNonemust keep working as before. - Add
--where EXPRESSIONto theselect,updateanddeletecommands of the command line tool, as described in the spec. - Add at least 25 unit tests for the language in
tests/test_query.py(unittest). Cover parsing and precedence, every operator, NULL handling, and the error classes including the error positions. - Document the feature in
README.md(a syntax summary, a Python example and a command line example).
Where the spec is precise (error positions, evaluation order, NULL logic, type errors) follow it exactly. Do not change SPEC.md or the existing tests, and keep them passing: python3 -m unittest discover -s tests. Use only the standard library and stay compatible with Python 3.9 or newer.
When you are done, reply with a short summary of what you implemented and which files you changed.