mapToSqlParameter method

  1. @override
Object mapToSqlParameter(
  1. GenerationContext context,
  2. DartT dartValue
)
override

Maps the dartValue to a value understood by the underlying database driver.

Implementation

@override
Object mapToSqlParameter(GenerationContext context, DartT dartValue) {
  if (context.dialect == SqlDialect.postgres) {
    // Enums are treated as null pgtype
    const PgType? pgType = null;
    final String enumStr = codec.encode(dartValue);
    return pg_mapping.mapToSql(pgType, enumStr);
  } else {
    return super.mapToSqlParameter(context, dartValue);
  }
}