ErrorsReads and writes · rule
query.limit_range
A query's limit: could be less than 1, either as written or because its value's type allows it.
Area 6, Reads and writes; not declinable; the next step is usually the agent's.
Why Jadpo refuses it
limit: is the most records a list query gives back. A limit of 0 would
read nothing, and PostgreSQL refuses a negative one. So a limit is at
least 1: a number written from 1, or a value whose type says min: 1 or
more.
What it looks like
main.jadpo:
type Title = Text { max_length: 80}entity Book { id: Uuid title: Title subtitle: Title? available: Bool}query shelf() -> List<Book> { from: Book order: [Book.title asc] limit: 0}
error limit: 0 would read nothing
--> main.jadpo:15:12
|15 | limit: 0 | ^ below 1
- reason
limit:is how many records come back at most, so it is at least 1.- next
- Give
limit:a number from 1 (agent) - rule
- query.
limit_ range - help
- https://jadpo.
dev/docs/errors/query. limit_ range
(agent) at the end of the next: line means your coding agent can make
the fix itself.
A limit given as a parameter is refused when its type lets it be below 1.
Here ShelfSize has a max: but no min::
main.jadpo:
type Title = Text { max_length: 80}type ShelfSize = Int { max: 50}entity Book { id: Uuid title: Title}query shelf(size: ShelfSize) -> List<Book> { from: Book order: [Book.title asc] limit: size}
error size can be below 1, so the limit could read nothing
--> main.jadpo:17:12
|17 | limit: size | ^^^^ `ShelfSize` has no `min:`
- reason
limit:is how many records come back at most, so it is at least 1, and a value's type must say so withmin: 1or more, as the built-inPageSize(1 to 100) does.- next
- Give
ShelfSizemin: 1, or type the value asPageSize(agent) - rule
- query.
limit_ range - help
- https://jadpo.
dev/docs/errors/query. limit_ range
How to fix it
If the limit is written as a number, write the most records the list should give, from 1:
limit: 50shelf gives up to 50 books, in title order.
If the limit is a parameter, give its type min: 1. main.jadpo
becomes:
type Title = Text { max_length: 80}type ShelfSize = Int { min: 1 max: 50}entity Book { id: Uuid title: Title}query shelf(size: ShelfSize) -> List<Book> { from: Book order: [Book.title asc] limit: size}
shelf gives up to size books. A number outside 1 to 50 can't be a
ShelfSize, so it never reaches the query.
If 1 to 100 suits the list, the parameter can be typed as the built-in
PageSize instead, and ShelfSize isn't needed.
Related
Markdown for agents: /docs/errors/query.limit_range.md.Built from Jadpo main at aee2e8f.