nullValue property

MssqlValue get nullValue

A typed null for this column.

Implementation

MssqlValue get nullValue {
  // Characters are declared in bytes, and an n-type stores two per
  // character; a `max` column reports -1, which the driver reads as
  // "unbounded" when the size is left at zero.
  final chars = maxLength < 0 ? 0 : maxLength;
  final wideChars = maxLength < 0 ? 0 : maxLength ~/ 2;
  return switch (type) {
    MssqlType.bit => const MssqlValue.bit(null),
    MssqlType.tinyInt => const MssqlValue.tinyInt(null),
    MssqlType.smallInt => const MssqlValue.smallInt(null),
    MssqlType.int32 => const MssqlValue.int32(null),
    MssqlType.int64 => const MssqlValue.int64(null),
    MssqlType.real => const MssqlValue.real(null),
    MssqlType.float64 => const MssqlValue.float64(null),
    MssqlType.decimal => MssqlValue.decimal(
      null,
      precision: precision,
      scale: scale,
    ),
    MssqlType.numeric => MssqlValue.numeric(
      null,
      precision: precision,
      scale: scale,
    ),
    MssqlType.money => MssqlValue.money(null),
    MssqlType.smallMoney => MssqlValue.smallMoney(null),
    MssqlType.char => MssqlValue.char(null, size: chars == 0 ? 1 : chars),
    MssqlType.varchar => MssqlValue.varchar(null, size: chars),
    MssqlType.nchar => MssqlValue.nchar(
      null,
      size: wideChars == 0 ? 1 : wideChars,
    ),
    MssqlType.nvarchar => MssqlValue.nvarchar(null, size: wideChars),
    MssqlType.text => const MssqlValue.text(null),
    MssqlType.ntext => const MssqlValue.ntext(null),
    MssqlType.binary => MssqlValue.binary(null, size: chars == 0 ? 1 : chars),
    MssqlType.varbinary => MssqlValue.varbinary(null, size: chars),
    MssqlType.image => const MssqlValue.image(null),
    MssqlType.date => MssqlValue.date(null),
    MssqlType.time => MssqlValue.time(null, scale: scale),
    MssqlType.smallDateTime => MssqlValue.smallDateTime(null),
    MssqlType.dateTime => MssqlValue.dateTime(null),
    MssqlType.dateTime2 => MssqlValue.dateTime2(null, scale: scale),
    MssqlType.dateTimeOffset => MssqlValue.dateTimeOffset(null, scale: scale),
    MssqlType.uniqueIdentifier => const MssqlValue.uniqueIdentifier(null),
    MssqlType.xml => const MssqlValue.xml(null),
  };
}