Skip to main content
This page is a formal grammar reference for Sync Streams: it shows the syntax the compiler accepts using railroad diagrams. This page complements the Supported SQL guide, which explains in prose what you can write, with examples and restrictions. When to use this page: If you need to check whether a construct is valid, see how rules nest (e.g. subqueries, CTEs, JOINs), or you’re used to grammar specs, use the diagrams and the “Used by” / “References” links to navigate. For most users just getting started, see Supported SQL and Writing Queries.

SelectStatement

References: FromSource, JoinClause, SelectItem, WhereClause

SelectItem

References: Expression, Identifier, Reference

Reference

References: Identifier

FromSource

References: SubquerySource, TableSource, TableValuedSource

TableSource

References: Identifier, Reference

TableValuedCall

References: Expression, Identifier

TableValuedSource

References: Identifier, TableValuedCall

SubquerySource

References: Identifier, Subquery

JoinClause

References: FromSource, WhereClause

WhereClause

References: Condition

Condition

References: Expression, PredicateTail, WhereClause

PredicateTail

References: Expression, InSource

InSource

References: Expression, Identifier, Subquery

Expression

Operators

Binary operators supported in scalar expressions, listed from highest to lowest precedence.
PowerSync evaluates all binary operators with equal precedence (left to right). Use parentheses to control evaluation order.
References: PrimaryExpression, PropertyAccess

PropertyAccess

References: IntegerLiteral, StringLiteral

PrimaryExpression

References: CaseExpression, CastExpression, Expression, FunctionCall, NumericLiteral, Reference, StringLiteral

CaseExpression

References: SearchedCase, SimpleCase

SearchedCase

References: Expression, WhenClause

WhenClause

References: CaseCondition, Expression, WhenClause

CaseCondition

References: Condition

SimpleCase

References: Expression, WhenValueClause

WhenValueClause

References: Expression, WhenValueClause

CastExpression

References: Expression

FunctionCall

References: Expression, Reference

Subquery

References: FromSource, JoinClause, SelectItem, WhereClause

CteDefinition

References: Expression, FromSource, Identifier, JoinClause, WhereClause

Lexical Rules

Identifier

Bare identifiers are normalized to lower case and may contain letters, digits, and underscores. Double-quoted identifiers (“name”) allow any printable character and support escaped quotes ("").

StringLiteral

Single-quoted string literal. Embedded single quotes are escaped by doubling them (”).

IntegerLiteral

One or more decimal digits (0-9).

NumericLiteral

Decimal number: one or more digits with an optional fractional part (.digits).