validateDirectedOutInOut function

void validateDirectedOutInOut(
  1. ParamDirection direction,
  2. ParamValue pv
)

Client-side checks for DRT1 OUT / INOUT that the native engine will reject; fails fast with the same slugs as output_aware_params.rs.

Implementation

void validateDirectedOutInOut(ParamDirection direction, ParamValue pv) {
  if (direction == ParamDirection.input) {
    return;
  }
  if (pv is ParamValueRefCursorOut) {
    if (direction != ParamDirection.output) {
      throw ArgumentError.value(
        pv,
        'value',
        '${kDirectedParamErrorPrefix}ref_cursor_out_invalid_direction: '
        'ParamValueRefCursorOut is only valid for ParamDirection.output',
      );
    }
    return;
  }
  if (pv is ParamValueBinary) {
    throw ArgumentError.value(
      pv,
      'value',
      '${kDirectedParamErrorPrefix}binary_out_inout_not_implemented: '
      'OUT/INOUT for binary columns is not implemented; use Integer, '
      'BigInt, String, or Decimal (see TYPE_MAPPING ยง3.1)',
    );
  }
  if (pv is ParamValueNull) {
    if (direction == ParamDirection.inOut) {
      throw ArgumentError.value(
        pv,
        'value',
        '${kDirectedParamErrorPrefix}inout_null: INOUT with ParamValueNull '
        'is not supported; pass Integer, BigInt, String, or non-empty '
        'Decimal',
      );
    }
    return;
  }
  if (pv is ParamValueDecimal) {
    if (pv.value.isEmpty) {
      throw ArgumentError.value(
        pv,
        'value',
        '${kDirectedParamErrorPrefix}decimal_inout_out_requires_non_empty: '
        'use a non-empty ParamValue::Decimal for OUT/INOUT or use String',
      );
    }
  }
}