ErrorsPersonal data · rule
data.lookup_not_unique
Code looks a record up by an email field that isn't unique: true across the whole table, so an address could find several.
Area 15, Personal data; not declinable; the next step is usually the human's.
Why Jadpo refuses it
A lookup gives one record or none. If several records could hold one
address, which came back would show more than one person's. So the field
must be unique: true, and its entity one every tenant shares: a
tenant's unique rule holds only within the tenant, so two tenants'
records may hold the same address.
What it looks like
main.jadpo:
principal { user: { subject: Member.handle }}authentication { api_token: {}}policy { actions: { has_account: [Access.authenticated] }}type Handle = Text { max_length: 40}type AddressStanding = Enum { account_held no_account}entity Member { id: Uuid handle: Handle { unique: true } email: Email policy: { create: [Access.public] read: [id] }}/// Whether an address has an account.action has_account(email: Member.email) -> AddressStanding { match Member.lookup(email: email) { none -> { return AddressStanding.no_account } some -> { return AddressStanding.account_held } }}
error Member.lookup finds by email, which isn't unique: true
--> main.jadpo:41:25
|41 | match Member.lookup(email: email) { | ^^^^^ not unique
- reason
- A lookup gives one record or none. Without
unique: trueseveralMemberrecords could hold one address, and which came back would show more than one person's. - next
- Make
Member.emailunique: true, if one address is one person's (human) - rule
- data.
lookup_ not_ unique - help
- https://jadpo.
dev/docs/errors/data. lookup_ not_ unique
(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 whether two of your records may share an address.
How to fix it
If one address is one person's, make the field unique: true:
email: Email { unique: true }
Two members can no longer share an address, and the lookup finds the one who has it, or none.
Related
Markdown for agents: /docs/errors/data.lookup_not_unique.md.Built from Jadpo's main branch at commit 9080dc3.