SQL Expression Language
Used in @check, @default, and @initialize_as. This is not raw SQL. Immigrant has its own expression syntax that compiles to SQL.
Operators
| Precedence | Operator | SQL equivalent |
|---|---|---|
Highest |
|
|
|
|
|
|
|
|
|
same |
|
|
|
|
|
|
|
|
|
|
|
|
|
Lowest |
|
|
Other expressions
table Example {
a: sql"INTEGER"
/// placeholder for current value
@check(_ > 0)
/// null literal
@check(_ != null)
/// boolean literal
@check(_ == true)
/// string literal
@check(_ != 'forbidden')
/// numeric literal
@check(_ != 42)
/// function call
@check(char_length(_) > 0)
/// cast
@check(_ :: BIGINT > 0)
/// conditional (CASE WHEN ... THEN ... ELSE ... END)
@check(if _ > 10 then true else false)
;
};
/// field access on composites
struct example {
a: sql"INTEGER";
@check(_.a > 0);
};