asInt method

Expr<int> asInt()

Cast as integer.

In SQL often translates to CAST(value AS BIGINT).

This is unsafe and may cause runtime errors.

The behavior is also database dependent.

  • sqlite will return 0 when parsing fails.
  • postgres will abort the query when parsing fails.

Example:

  • '123' -> 123

Implementation

Expr<int> asInt() => CastExpression._(this, ColumnType.integer);