update sqlTypeName for MariaDB

This commit is contained in:
BananaMasterz 2023-07-18 22:36:11 +03:00
parent bf75fdb72f
commit 125325b9f0
1 changed files with 24 additions and 6 deletions

View File

@ -321,22 +321,40 @@ enum DriftSqlType<T extends Object> implements _InternalDriftSqlType<T> {
// ignore: unnecessary_cast // ignore: unnecessary_cast
switch (this as DriftSqlType<Object>) { switch (this as DriftSqlType<Object>) {
case DriftSqlType.bool: case DriftSqlType.bool:
return dialect == SqlDialect.sqlite ? 'INTEGER' : 'boolean'; return dialect == SqlDialect.sqlite
? 'INTEGER'
: dialect == SqlDialect.mariadb
? 'BOOL'
: 'boolean';
case DriftSqlType.string: case DriftSqlType.string:
return dialect == SqlDialect.sqlite ? 'TEXT' : 'text'; return dialect == SqlDialect.sqlite || dialect == SqlDialect.mariadb
? 'TEXT'
: 'text';
case DriftSqlType.bigInt: case DriftSqlType.bigInt:
case DriftSqlType.int: case DriftSqlType.int:
return dialect == SqlDialect.sqlite ? 'INTEGER' : 'bigint'; return dialect == SqlDialect.sqlite
? 'INTEGER'
: dialect == SqlDialect.mariadb
? 'INT'
: 'bigint';
case DriftSqlType.dateTime: case DriftSqlType.dateTime:
if (context.typeMapping.storeDateTimesAsText) { if (context.typeMapping.storeDateTimesAsText) {
return dialect == SqlDialect.sqlite ? 'TEXT' : 'text'; return dialect == SqlDialect.sqlite || dialect == SqlDialect.mariadb
? 'TEXT'
: 'text';
} else { } else {
return dialect == SqlDialect.sqlite ? 'INTEGER' : 'bigint'; return dialect == SqlDialect.sqlite ? 'INTEGER' : 'bigint';
} }
case DriftSqlType.blob: case DriftSqlType.blob:
return dialect == SqlDialect.sqlite ? 'BLOB' : 'bytea'; return dialect == SqlDialect.sqlite || dialect == SqlDialect.mariadb
? 'BLOB'
: 'bytea';
case DriftSqlType.double: case DriftSqlType.double:
return dialect == SqlDialect.sqlite ? 'REAL' : 'float8'; return dialect == SqlDialect.sqlite
? 'REAL'
: dialect == SqlDialect.mariadb
? 'DOUBLE'
: 'float8';
case DriftSqlType.any: case DriftSqlType.any:
return 'ANY'; return 'ANY';
} }