Boolean Logic
Boolean Operators
Section titled “Boolean Operators”FlyQL uses three boolean operators to combine conditions:
| Operator | Meaning | Example |
|---|---|---|
and | Both conditions must be true | status = 200 and active |
or | Either condition can be true | level = 'error' or level = 'critical' |
not | Negates the immediately following expression or group | not archived |
Combined Negation
Section titled “Combined Negation”not can be combined with and and or:
active and not archived
level = 'error' or not healthy
Operator Precedence
Section titled “Operator Precedence”FlyQL follows standard operator precedence — the same rules as SQL, Python, JavaScript, Go, and every mainstream query language:
| Precedence | Operator | Binds |
|---|---|---|
| 1 (tightest) | not | To its immediate operand — the following expression or parenthesized group |
| 2 | and | Tighter than or |
| 3 (loosest) | or | Loosest — combines whole AND-chains |
Concretely:
a = 1 or b = 2 and c = 3
is parsed as:
a = 1 or (b = 2 and c = 3)
because and binds tighter than or. Same-precedence chains are left-associative, so a = 1 and b = 2 and c = 3 parses as (a = 1 and b = 2) and c = 3.
not binds tightest and applies only to the expression or group that follows it — never the entire preceding expression.
Parenthesized Grouping
Section titled “Parenthesized Grouping”Use parentheses to override the default precedence when you want or evaluated before and:
(status >= 400 or level = 'error') and service = 'api'
Without the parentheses, the same source
status >= 400 or level = 'error' and service = 'api'
parses as
status >= 400 or (level = 'error' and service = 'api')
which is a different query. When you want or to dominate, reach for parentheses explicitly.
Nested Grouping
Section titled “Nested Grouping”Parentheses can be nested:
(a = 1 or b = 2) and not (c = 3 and d = 4)
Negating Groups
Section titled “Negating Groups”not applies to the entire group:
not (status = 200 and healthy)
This negates the combined condition — true only when either status is not 200 or healthy is false.
Negation
Section titled “Negation”not negates any expression — a truthy check, a comparison, or a group:
not active
not status = 200
not (a = 1 and b = 2)
active and not archived
Double negation cancels out: not not active is equivalent to active.
Examples
Section titled “Examples”status = 200 and service = 'api'
level = 'error' or level = 'critical'
status >= 400 or level = 'error' and service = 'api'
(status >= 400 or level = 'error') and service = 'api'
(status >= 500 and host = 'prod') or (level = 'error' and not service = 'healthcheck')