bind method

SlotBinding<T> bind(
  1. Expr<T> expression
)

Binds an expression with its actual codec to this output slot.

Dart covariance can widen Expr<int> to Expr<num>; it cannot widen that expression's Codec<int> encoder. Such mismatches are rejected here. Supply an expression with an explicit target-type codec and SQL semantics instead.

Implementation

SlotBinding<T> bind(Expr<T> expression) {
  final codec = expression.codec;
  if (codec.valueType != T) {
    throw const OrmException(
      'PROJECTION.CODEC_TYPE',
      'The expression codec must have the exact slot value type. Use an explicit target-type codec or SQL conversion.',
    );
  }
  return SlotBinding._(
    this,
    Expr<T>.internal(expression.expressionNode, codec),
  );
}