Allow reading bigints as doubles

This commit is contained in:
Simon Binder 2023-09-29 00:06:51 +02:00
parent 3ecee4fb1f
commit d694b64e72
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
2 changed files with 7 additions and 0 deletions

View File

@ -191,6 +191,8 @@ class SqlTypes {
}
return sqlValue as T;
case DriftSqlType.double:
if (sqlValue case final BigInt bi) return bi.toDouble() as T;
return (sqlValue as num?)?.toDouble() as T;
case DriftSqlType.any:
return DriftAny(sqlValue) as T;

View File

@ -14,6 +14,11 @@ void main() {
expect(typeSystem.read(drift.DriftSqlType.double, null), isNull);
});
test('can read BigInt', () {
expect(typeSystem.read(drift.DriftSqlType.double, BigInt.parse('12345')),
12345.0);
});
test('can be mapped to sql constants', () {
expect(typeSystem.mapToSqlLiteral(1.123), '1.123');
});