compileDefault static method
The SQL of the default value of a column. A DateTime is UTC text, as
angel3_orm_sqlite stores one ('2024-03-10 12:34:56.000000Z'), and so
is currentTimestamp, where SQLite's CURRENT_TIMESTAMP would give UTC
without its Z, which Dart reads as local time.
Throws an ArgumentError for a double that is not finite, which SQLite
does not store, and for a DateTime of a year before 0 or after 9999.
Implementation
static String compileDefault(Object value) {
if (value is double && !value.isFinite) {
throw ArgumentError.value(value, null, 'SQLite has no NaN or infinity');
}
if (value is DateTime) {
return sql.quoteLiteral(SqliteDialect.formatDateTime(value));
}
if (value is RawSql &&
value.value.trim().toUpperCase() == 'CURRENT_TIMESTAMP') {
return "(strftime('%Y-%m-%d %H:%M:%f', 'now') || '000Z')";
}
return sql.compileDefault(value, escapeBackslashes: false);
}