mapToSqlConstant static method
Maps a Dart object to a SQL constant representing the same value.
Implementation
static String mapToSqlConstant(Object? dart) {
if (dart == null) return 'NULL';
// todo: Inline and remove types in the next major drift version
if (dart is bool) {
return const BoolType().mapToSqlConstant(dart);
} else if (dart is String) {
return const StringType().mapToSqlConstant(dart);
} else if (dart is int) {
return const IntType().mapToSqlConstant(dart);
} else if (dart is DateTime) {
return const DateTimeType().mapToSqlConstant(dart);
} else if (dart is Uint8List) {
return const BlobType().mapToSqlConstant(dart);
} else if (dart is double) {
return const RealType().mapToSqlConstant(dart);
}
throw ArgumentError.value(dart, 'dart',
'Must be null, bool, String, int, DateTime, Uint8List or double');
}