Skip to main content
Complete syntax reference for OneTest Query Language (OQL).

Query Structure

<filter_expression> [ORDER BY <field> [ASC|DESC]] [LIMIT <n>] [OFFSET <n>]
All parts except the filter expression are optional.

Operators

Comparison Operators

OperatorDescriptionExample
=Equalsstatus = active
!=Not equalspriority != p4
>Greater thanversion > 2.0
>=Greater or equalcreated_at >= 2024-01-01
<Less thanpriority < p2
<=Less or equalupdated_at <= -7d
IS NULLField is nulllast_run IS NULL
IS NOT NULLField is not nullfolder_id IS NOT NULL
BETWEENValue in rangecreated_at BETWEEN 2024-01-01 AND 2024-12-31

String Pattern Operators

OperatorDescriptionExample
~Contains (case-insensitive)title ~ "login"
!~Does not containdescription !~ "deprecated"
^Starts withidentifier ^ "TC-10"
$Ends withtitle $ "test"

List Operators

OperatorDescriptionExample
INValue in listpriority IN (p1, p2, p3)
NOT INValue not in liststatus NOT IN (archived, deleted)

Array Operators

OperatorDescriptionExample
CONTAINSArray contains valuetags CONTAINS "smoke"
NOT CONTAINSArray does not containtags NOT CONTAINS "deprecated"
CONTAINS ANYArray contains any valuetags CONTAINS ANY (smoke, regression)
CONTAINS ALLArray contains all valuestags CONTAINS ALL (smoke, critical)

Logical Operators

OperatorDescriptionExample
ANDBoth conditions must be truestatus = active AND priority = p1
OREither condition must be truepriority = p1 OR priority = p2
NOTNegate conditionNOT status = archived
( )Group conditions(status = active OR status = approved) AND priority = p1

Data Types

Strings

Enclose in double or single quotes:
title = "User Login"
title = 'User Login'
Use quotes for strings with spaces or special characters.

Numbers

No quotes needed:
version = 2
priority_number > 1

Booleans

automated = true
is_flaky = false

Dates

created_at = 2024-01-15
created_at = "2024-01-15T10:30:00Z"

Null Values

last_run IS NULL
description IS NOT NULL

Field Names

Field names are case-sensitive:
✅ status = active
❌ Status = active
❌ STATUS = active
For fields with spaces or special characters, use quotes:
"custom field" = "value"

Ordering

ORDER BY created_at DESC
ORDER BY priority ASC
ORDER BY title
Default order is ASC (ascending).

Pagination

# First 50 results
LIMIT 50

# Next 50 results
LIMIT 50 OFFSET 50

# Third page (rows 101-150)
LIMIT 50 OFFSET 100
OFFSET requires LIMIT to be specified.

Examples by Complexity

# Single condition
status = active

# With ordering
status = active ORDER BY created_at DESC

# With limit
priority = p1 LIMIT 10

Operator Precedence

From highest to lowest:
  1. ( ) - Parentheses
  2. NOT - Logical NOT
  3. =, !=, >, >=, <, <=, ~, ^, $, IN, CONTAINS - Comparison operators
  4. AND - Logical AND
  5. OR - Logical OR
Use parentheses to make precedence explicit: (A OR B) AND C

Common Patterns

# Has all these tags
tags CONTAINS ALL (smoke, critical, login)

# Has any of these tags
tags CONTAINS ANY (smoke, regression)

# Has this tag but not that tag
tags CONTAINS "smoke" AND tags NOT CONTAINS "deprecated"
# This month
created_at >= startOfMonth()

# Last 7 days
created_at >= -7d

# Specific range
created_at BETWEEN 2024-01-01 AND 2024-12-31

# Before a date
created_at < 2024-06-01
# Any of these priorities
priority IN (p0, p1, p2)

# Higher priority than P2
priority < p2

# Exclude low priorities
priority NOT IN (p3, p4)

Validation Rules

  • Field names must exist in the schema
  • Operators must match field types (can’t use ~ on numbers)
  • Date formats must be valid ISO 8601
  • Array operators only work on array fields
  • Priority values must be valid (p0-p4)

Error Messages

Common errors and how to fix them:
ErrorCauseFix
Unknown field: xyzField doesn’t existCheck field reference
Invalid operator for field typeWrong operator for fieldUse comparison operators for numbers, pattern operators for strings
Invalid date formatBad date syntaxUse ISO 8601: 2024-01-15 or relative: -7d
Expected AND/ORMissing logical operatorAdd AND or OR between conditions
Unclosed quoteMissing closing quoteEnsure all strings have matching quotes

What’s Next?