asDouble method

Expr<double> asDouble()

Cast as double.

In SQL often translates to CAST(value AS DOUBLE PRECISION).

This is unsafe and may cause runtime errors.

The behavior is also database dependent.

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

Example:

  • '3.14' -> 3.14

Implementation

Expr<double> asDouble() => CastExpression._(this, ColumnType.real);