Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
39 lines
3.0 KiB
Markdown
39 lines
3.0 KiB
Markdown
---
|
|
id: feature-query
|
|
title: Implement the where query language of minidb from its specification
|
|
kind: feature
|
|
expected_rounds: 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 and `SPEC.md` are byte-identical;
|
|
* the pristine visible tests pass (run from a clean copy of `tests/`);
|
|
* `hidden/test_hidden_spec.py` passes: 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 by `SPEC.md` alone;
|
|
* `tests/test_query.py` exists, has at least 25 test methods that contain an assertion call, mentions `minidb` and `where`, and passes (at least 25 tests run);
|
|
* `README.md` mentions `--where`.
|
|
|
|
## Prompt
|
|
<!-- PROMPT BEGIN -->
|
|
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:
|
|
|
|
1. Create `minidb/query.py` that implements `SPEC.md` exactly, including `compile_where(text, columns)` and the exception classes that the spec names.
|
|
2. Make `Table.select`, `Table.update`, `Table.delete` and `Table.count` accept a query string as `where`. Callables and `None` must keep working as before.
|
|
3. Add `--where EXPRESSION` to the `select`, `update` and `delete` commands of the command line tool, as described in the spec.
|
|
4. 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.
|
|
5. 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.
|
|
<!-- PROMPT END -->
|