typeToSQLType method

String? typeToSQLType(
  1. TypeInfo type,
  2. String column, {
  3. List<EntityField>? entityFieldAnnotations,
})

Implementation

String? typeToSQLType(TypeInfo type, String column,
    {List<EntityField>? entityFieldAnnotations}) {
  if (type.isString) {
    var maximum = entityFieldAnnotations?.maximum.firstOrNull;
    return maximum != null && maximum > 0 ? 'VARCHAR($maximum)' : 'VARCHAR';
  } else if (type.isBool) {
    return 'BOOLEAN';
  } else if (type.isDateTime) {
    return 'TIMESTAMP';
  } else if (type.type == Time) {
    return 'TIME';
  } else if (type.isDouble || type.type == Decimal) {
    return 'DECIMAL';
  } else if (type.isInt) {
    return 'INT';
  } else if (type.isBigInt || type.type == DynamicInt) {
    return 'BIGINT';
  } else if (type.isUInt8List) {
    return 'BLOB';
  }

  return null;
}