ErrorsReads and writes · rule
query.redis_unsupported
A query reads an entity kept in Redis in a way only a database can serve, such as a range, an include or an order.
Area 6, Reads and writes; not declinable; the next step is usually the human's.
Why Jadpo refuses it
Redis keeps no indexes of its own. Jadpo finds a record there by its
id, by the key it keeps for each value of a field with unique: true,
or, for a field indexes: lists, by the set it keeps for each value,
which gives a page in creation order and its count(). A query that
asks anything else, a range, in, or, an order:, an include:,
matches, a search inside text or a geo. test, would have to read
every record, and Redis keeps no list of them.
What it looks like
app.jadpo declares drafts, a Redis connection:
domains/accounts/entities/sign_up_draft.jadpo:
use accounts/types { Attempts }/// A sign-up someone has started and not yet finished.entity SignUpDraft { id: Uuid email: Email attempts: Attempts store: drafts expires_after: 2h indexes: { by_attempts: [attempts] }}
domains/accounts/queries/locked_out.jadpo:
use accounts/entities { SignUpDraft }/// The sign-ups that have used up their tries.query locked_out() -> List<SignUpDraft> { from: SignUpDraft where: SignUpDraft.attempts >= 5 limit: 50}
error locked_out reads SignUpDraft, kept in Redis, with a range
--> domains/accounts/queries/locked_out.jadpo:6:5
|6 | where: SignUpDraft.attempts >= 5 | ^^^^^ only a database can
- reason
draftsis a Redis connection. Redis keeps no order of a field's values, only a set for each one, so it finds records holding a value and nothing between two. A query of an entity in Redis finds records byid, by a field withunique: true, or by==on one fieldindexes:lists, a page in creation order or itscount().- next
- Keep
SignUpDraftin a PostgreSQL store, or find its records byid, a unique field or an indexed one (human) - rule
- query.
redis_ unsupported - help
- https://jadpo.
dev/docs/errors/query. redis_ unsupported
A search inside text reads a trigram index, which Redis doesn't keep either:
domains/accounts/queries/drafts_from.jadpo:
use accounts/entities { SignUpDraft }/// The sign-ups whose address holds what someone typed.query drafts_from(part: SignUpDraft.email) -> List<SignUpDraft> { from: SignUpDraft where: text.contains_ignoring_case(SignUpDraft.email, part) limit: 50}
error drafts_from reads SignUpDraft, kept in Redis, with a search inside text, text.contains_ignoring_case
--> domains/accounts/queries/drafts_from.jadpo:6:5
|6 | where: text.contains_ignoring_case(SignUpDraft.email, part) | ^^^^^ only a database can
- reason
draftsis a Redis connection. A search inside text reads a trigram index, which only PostgreSQL keeps. A query of an entity in Redis finds records byid, by a field withunique: true, or by==on one fieldindexes:lists, a page in creation order or itscount().- next
- Keep
SignUpDraftin a PostgreSQL store, or find its records byid, a unique field or an indexed one (human) - rule
- query.
redis_ unsupported - help
- https://jadpo.
dev/docs/errors/query. redis_ unsupported
(human) at the end of the next: line tells your coding agent to stop
and ask you which fix you want, because the choice is yours to make: it
decides where the records are kept, and which of them the query finds.
How to fix it
If the records belong in a database, keep the entity there, and the query reads them as it is:
entity SignUpDraft { id: Uuid email: Email attempts: Attempts}
The range is now one WHERE in PostgreSQL.
If they stay in Redis, test one value with ==, which the set Jadpo
keeps for each value of attempts serves:
query locked_out() -> List<SignUpDraft> { from: SignUpDraft where: SignUpDraft.attempts == 5 limit: 50}
The query now reads the sign-ups that have tried exactly five codes, in the order they were made.
Related
Markdown for agents: /docs/errors/query.redis_unsupported.md.Built from Jadpo's main branch at commit 9080dc3.