Skip to content

Boolean Logic

FlyQL uses three boolean operators to combine conditions:

OperatorMeaningExample
andBoth conditions must be truestatus = 200 and active
orEither condition can be truelevel = 'error' or level = 'critical'
notNegates the immediately following expression or groupnot archived

not can be combined with and and or:

active and not archived
level = 'error' or not healthy

FlyQL follows standard operator precedence — the same rules as SQL, Python, JavaScript, Go, and every mainstream query language:

PrecedenceOperatorBinds
1 (tightest)notTo its immediate operand — the following expression or parenthesized group
2andTighter than or
3 (loosest)orLoosest — 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.

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.

Parentheses can be nested:

(a = 1 or b = 2) and not (c = 3 and d = 4)

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.

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.

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')