ErrorsReads and writes · rule
query.section_required
A query leaves out a section its result type needs, such as from:, or the limit: that bounds a list.
Area 6, Reads and writes; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
A query's result type says how many records come back, and each kind of
result needs sections of its own. Every query names the entity it reads
in from:. A list needs order: and limit:, because every list is
bounded: a query that could read a whole table would grow slower as the
table grows, with nothing in the code to show it.
What it looks like
main.jadpo:
type Title = Text { max_length: 80}entity Book { id: Uuid title: Title subtitle: Title? available: Bool}query books_titled(title: Book.title) -> List<Book> { from: Book where: Book.title == title order: [Book.id asc]}
error books_titled returns List<Book> but has no limit:
--> main.jadpo:12:7
|12 | query books_titled(title: Book.title) -> List<Book> { | ^^^^^^^^^^^^ no `limit:`
- reason
- Every list is bounded:
limit:is a number, or a value whose type has amax:. - next
- Add
limit: <number>, or returnPage<T>to read it a page at a time (agent) - rule
- query.
section_ required - help
- https://jadpo.
dev/docs/errors/query. section_ required
(agent) at the end of the next: line means your coding agent can make
the fix itself.
A query with no from: is refused in the same way, since nothing says
which entity its conditions and order are about:
main.jadpo:
type Title = Text { max_length: 80}entity Book { id: Uuid title: Title subtitle: Title? available: Bool}query books_titled(title: Book.title) -> List<Book> { where: Book.title == title order: [Book.id asc] limit: 20}
error books_titled doesn't say what it reads
--> main.jadpo:12:7
|12 | query books_titled(title: Book.title) -> List<Book> { | ^^^^^^^^^^^^ no `from:`
- reason
- A query reads one entity, named in
from:; its conditions, order and includes are about that entity's records. - next
- Add
from: <Entity>as the query's first line (agent) - rule
- query.
section_ required - help
- https://jadpo.
dev/docs/errors/query. section_ required
How to fix it
If a fixed number of books is enough, add limit::
order: [Book.id asc] limit: 20
The query gives up to 20 books with that title.
If the caller should be able to read every one, return a Page<Book>
and read it a page at a time. The caller passes the page size and the
cursor from the page before:
query books_titled(title: Book.title, size: PageSize, after: PageCursor?) -> Page<Book> { from: Book where: Book.title == title order: [Book.id asc] page: { size: size after: after }}
Each call gives up to size books, at most 100, and a next cursor
while more remain. Passing that cursor back as after gives the next
page.
If the query has no from:, add it as the first line, naming the
entity it reads:
from: BookThe query reads Book records, and its where: and order: test their
fields.
Related
Markdown for agents: /docs/errors/query.section_required.md.Built from Jadpo main at aee2e8f.