Pattern Matching
The is operator goes beyond checking which variant a field holds — it can also
inspect and bind the data inside a variant's payload.
Matching a Specific Payload Value
Pass a concrete value inside parentheses to match only rows whose variant payload equals that value:
select * from main.users where bio is Option.Some("TempestDB enthusiast");
This returns only Alice.
Binding a Payload with a Wildcard
Use an identifier instead of a literal to bind the inner value to a name.
A bare identifier is a wildcard — it matches any value and makes it available
to the rest of the where clause:
select * from main.users where bio is Option.Some(b) and b = "Loves databases";
b is bound to the string inside Some, then tested with =. This returns
only Charlie.
Using a Wildcard as an Existence Check
A wildcard with no further conditions is simply a check that the variant matches at all:
select * from main.users where bio is Option.Some(b);
This returns every user with a non-None bio — Alice and Charlie, but not Bob.
Combining Conditions
is composes with and and or like any other predicate:
select * from main.users where bio is Option.None or bio is Option.Some("Loves databases");
Pattern Matching on Custom Enums
Everything above works with your own enum types too. Given a main.Status enum
with a Pending(Int64) variant carrying a priority level:
create type main.Priority enum { Low, High(Int64) };
create type main.Task struct { id: Int64, priority: main.Priority };
create table main.tasks : main.Task { primary key (id) };
insert into main.tasks { id: 1, priority: main.Priority.Low };
insert into main.tasks { id: 2, priority: main.Priority.High(1) };
insert into main.tasks { id: 3, priority: main.Priority.High(99) };
Match on the variant and further filter on its payload:
select * from main.tasks where priority is main.Priority.High(level) and level > 10;
This returns only task 3.