mirror of https://github.com/AMT-Cheif/drift.git
Move dialect to SqlTypes constructor, re-generate
This commit is contained in:
parent
54b58948d3
commit
d491db8599
|
@ -168,10 +168,10 @@ class $TodoCategoriesTable extends TodoCategories
|
|||
TodoCategory map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return TodoCategory(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
name: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}name'], attachedDatabase.executor.dialect)!,
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
name: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -449,20 +449,16 @@ class $TodoItemsTable extends TodoItems
|
|||
TodoItem map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return TodoItem(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
title: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}title'], attachedDatabase.executor.dialect)!,
|
||||
content: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}content'], attachedDatabase.executor.dialect),
|
||||
categoryId: attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}category_id'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
generatedText: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}generated_text'],
|
||||
attachedDatabase.executor.dialect),
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
title: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
||||
content: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}content']),
|
||||
categoryId: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}category_id'])!,
|
||||
generatedText: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}generated_text']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -548,12 +544,10 @@ class $TodoCategoryItemCountView
|
|||
{String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return TodoCategoryItemCountData(
|
||||
name: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}name'], attachedDatabase.executor.dialect)!,
|
||||
itemCount: attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}item_count'],
|
||||
attachedDatabase.executor.dialect),
|
||||
name: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||
itemCount: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}item_count']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -655,10 +649,10 @@ class $TodoItemWithCategoryNameViewView extends ViewInfo<
|
|||
{String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return TodoItemWithCategoryNameViewData(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
title: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}title'], attachedDatabase.executor.dialect),
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
title: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}title']),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,10 @@ abstract class DatabaseConnectionUser {
|
|||
/// values. In the future, they could be expanded to dialect-specific options.
|
||||
DriftDatabaseOptions get options => attachedDatabase.options;
|
||||
|
||||
/// A [SqlTypes] mapping configuration to use when mapping values between Dart
|
||||
/// and SQL.
|
||||
late final SqlTypes typeMapping = options.createTypeMapping(executor.dialect);
|
||||
|
||||
/// The database class that this user is attached to.
|
||||
@visibleForOverriding
|
||||
GeneratedDatabase get attachedDatabase;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import '../types/mapping.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
|
||||
/// Database-specific options used by drift.
|
||||
///
|
||||
|
@ -7,8 +7,11 @@ import '../types/mapping.dart';
|
|||
class DriftDatabaseOptions {
|
||||
/// Configuration for [SqlTypes] describing how to map Dart values from and to
|
||||
/// SQL values.
|
||||
@Deprecated('UsecreateTypeMapping instead')
|
||||
final SqlTypes types;
|
||||
|
||||
final bool _storeDateTimeAsText;
|
||||
|
||||
/// Creates database-specific database options.
|
||||
///
|
||||
/// When [storeDateTimeAsText] is enabled (it defaults to `false` for
|
||||
|
@ -20,6 +23,13 @@ class DriftDatabaseOptions {
|
|||
/// [the documentation]: https://drift.simonbinder.eu/docs/getting-started/advanced_dart_tables/#supported-column-types
|
||||
const DriftDatabaseOptions({
|
||||
bool storeDateTimeAsText = false,
|
||||
}) : types =
|
||||
}) : _storeDateTimeAsText = storeDateTimeAsText,
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
types =
|
||||
storeDateTimeAsText ? const SqlTypes(true) : const SqlTypes(false);
|
||||
|
||||
/// Creates a type mapping suitable for these options and the given [dialect].
|
||||
SqlTypes createTypeMapping(SqlDialect dialect) {
|
||||
return SqlTypes(_storeDateTimeAsText, dialect);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ class _BetweenExpression extends Expression<bool> {
|
|||
|
||||
// We don't want to compare datetime values lexicographically, so we convert
|
||||
// them to a comparable unit
|
||||
if (context.options.types.storeDateTimesAsText) {
|
||||
if (context.typeMapping.storeDateTimesAsText) {
|
||||
if (target is Expression<DateTime>) target = target.julianday;
|
||||
if (lower is Expression<DateTime>) lower = lower.julianday;
|
||||
if (higher is Expression<DateTime>) higher = higher.julianday;
|
||||
|
|
|
@ -260,7 +260,7 @@ class _StrftimeSingleFieldExpression extends Expression<int> {
|
|||
context.buffer.write("CAST(strftime('$format', ");
|
||||
date.writeInto(context);
|
||||
|
||||
if (!context.options.types.storeDateTimesAsText) {
|
||||
if (!context.typeMapping.storeDateTimesAsText) {
|
||||
context.buffer.write(", 'unixepoch'");
|
||||
}
|
||||
context.buffer.write(') AS INTEGER)');
|
||||
|
@ -300,7 +300,7 @@ class _DependingOnDateTimeExpression<D extends Object> extends Expression<D> {
|
|||
Object.hash(_DependingOnDateTimeExpression, forTimestamps, forIsoString);
|
||||
|
||||
Expression<D> _expressionForContext(GenerationContext context) {
|
||||
if (context.options.types.storeDateTimesAsText) {
|
||||
if (context.typeMapping.storeDateTimesAsText) {
|
||||
return forIsoString;
|
||||
} else {
|
||||
return forTimestamps;
|
||||
|
|
|
@ -330,7 +330,7 @@ class _Comparison extends InfixOperator<bool> {
|
|||
|
||||
if (left is Expression<DateTime> &&
|
||||
right is Expression<DateTime> &&
|
||||
context.options.types.storeDateTimesAsText) {
|
||||
context.typeMapping.storeDateTimesAsText) {
|
||||
// Compare julianday values instead of texts
|
||||
writeInner(context, left.julianday);
|
||||
context.writeWhitespace();
|
||||
|
|
|
@ -60,7 +60,7 @@ class Variable<T extends Object> extends Expression<T> {
|
|||
/// database engine. For instance, a [DateTime] will me mapped to its unix
|
||||
/// timestamp.
|
||||
dynamic mapToSimpleValue(GenerationContext context) {
|
||||
return context.options.types.mapToSqlVariable(value, context.dialect);
|
||||
return context.typeMapping.mapToSqlVariable(value);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -120,10 +120,7 @@ class Constant<T extends Object> extends Expression<T> {
|
|||
|
||||
@override
|
||||
void writeInto(GenerationContext context) {
|
||||
context.buffer.write(context.options.types.mapToSqlLiteral(
|
||||
value,
|
||||
context.dialect,
|
||||
));
|
||||
context.buffer.write(context.typeMapping.mapToSqlLiteral(value));
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -20,8 +20,12 @@ class GenerationContext {
|
|||
final List<ResultSetImplementation> watchedTables = [];
|
||||
|
||||
/// The options to use when mapping values from and to the database.
|
||||
@Deprecated('Use typeMapping instead')
|
||||
final DriftDatabaseOptions options;
|
||||
|
||||
/// The [SqlTypes] configuration used for mapping values to the database.
|
||||
final SqlTypes typeMapping;
|
||||
|
||||
/// The [SqlDialect] that should be respected when generating the query.
|
||||
SqlDialect get dialect => executor?.executor.dialect ?? SqlDialect.sqlite;
|
||||
|
||||
|
@ -58,12 +62,16 @@ class GenerationContext {
|
|||
/// database.
|
||||
GenerationContext.fromDb(DatabaseConnectionUser this.executor,
|
||||
{this.supportsVariables = true})
|
||||
: options = executor.options;
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
: options = executor.options,
|
||||
typeMapping = executor.typeMapping;
|
||||
|
||||
/// Constructs a custom [GenerationContext] by setting the fields manually.
|
||||
/// See [GenerationContext.fromDb] for a more convenient factory.
|
||||
GenerationContext(this.options, this.executor,
|
||||
{this.supportsVariables = true});
|
||||
{this.supportsVariables = true})
|
||||
: typeMapping = options
|
||||
.createTypeMapping(executor?.executor.dialect ?? SqlDialect.sqlite);
|
||||
|
||||
/// Introduces a variable that will be sent to the database engine. Whenever
|
||||
/// this method is called, a question mark should be added to the [buffer] so
|
||||
|
|
|
@ -81,11 +81,7 @@ class QueryRow {
|
|||
/// support non-nullable types.
|
||||
T read<T>(String key) {
|
||||
final type = DriftSqlType.forNullableType<T>();
|
||||
return _db.options.types.read(
|
||||
type,
|
||||
data[key],
|
||||
_db.executor.dialect,
|
||||
) as T;
|
||||
return _db.typeMapping.read(type, data[key]) as T;
|
||||
}
|
||||
|
||||
/// Reads a nullable value from this row.
|
||||
|
@ -94,11 +90,7 @@ class QueryRow {
|
|||
/// drift (e.g. booleans, strings, numbers, dates, `Uint8List`s).
|
||||
T? readNullable<T extends Object>(String key) {
|
||||
final type = DriftSqlType.forType<T>();
|
||||
return _db.options.types.read(
|
||||
type,
|
||||
data[key],
|
||||
_db.executor.dialect,
|
||||
);
|
||||
return _db.typeMapping.read(type, data[key]);
|
||||
}
|
||||
|
||||
/// Reads a bool from the column named [key].
|
||||
|
|
|
@ -253,11 +253,7 @@ class JoinedSelectStatement<FirstT extends HasResultSet, FirstD>
|
|||
final expr = aliasedColumn.key;
|
||||
final value = row[aliasedColumn.value];
|
||||
|
||||
readColumns[expr] = ctx.options.types.read(
|
||||
expr.driftSqlType,
|
||||
value,
|
||||
ctx.dialect,
|
||||
);
|
||||
readColumns[expr] = ctx.typeMapping.read(expr.driftSqlType, value);
|
||||
}
|
||||
|
||||
return TypedResult(readTables, QueryRow(row, database), readColumns);
|
||||
|
|
|
@ -28,16 +28,16 @@ class SqlTypes {
|
|||
/// [the documentation]: https://drift.simonbinder.eu/docs/getting-started/advanced_dart_tables/#supported-column-types
|
||||
final bool storeDateTimesAsText;
|
||||
|
||||
final SqlDialect _dialect;
|
||||
|
||||
/// Creates an [SqlTypes] mapper from the provided options.
|
||||
@internal
|
||||
const SqlTypes(this.storeDateTimesAsText);
|
||||
const SqlTypes(this.storeDateTimesAsText,
|
||||
[this._dialect = SqlDialect.sqlite]);
|
||||
|
||||
/// Maps a Dart object to a (possibly simpler) object that can be used as a
|
||||
/// parameter in raw sql queries.
|
||||
Object? mapToSqlVariable(
|
||||
Object? dartValue, [
|
||||
SqlDialect dialect = SqlDialect.sqlite,
|
||||
]) {
|
||||
Object? mapToSqlVariable(Object? dartValue) {
|
||||
if (dartValue == null) return null;
|
||||
|
||||
// These need special handling, all other types are a direct mapping
|
||||
|
@ -74,7 +74,7 @@ class SqlTypes {
|
|||
}
|
||||
}
|
||||
|
||||
if (dartValue is bool && dialect == SqlDialect.sqlite) {
|
||||
if (dartValue is bool && _dialect == SqlDialect.sqlite) {
|
||||
return dartValue ? 1 : 0;
|
||||
}
|
||||
|
||||
|
@ -83,15 +83,12 @@ class SqlTypes {
|
|||
|
||||
/// Maps the [dart] value into a SQL literal that can be embedded in SQL
|
||||
/// queries.
|
||||
String mapToSqlLiteral(
|
||||
Object? dart, [
|
||||
SqlDialect dialect = SqlDialect.sqlite,
|
||||
]) {
|
||||
String mapToSqlLiteral(Object? dart) {
|
||||
if (dart == null) return 'NULL';
|
||||
|
||||
// todo: Inline and remove types in the next major drift version
|
||||
if (dart is bool) {
|
||||
if (dialect == SqlDialect.sqlite) {
|
||||
if (_dialect == SqlDialect.sqlite) {
|
||||
return dart ? '1' : '0';
|
||||
} else {
|
||||
return dart ? 'true' : 'false';
|
||||
|
@ -109,7 +106,7 @@ class SqlTypes {
|
|||
return dart.toString();
|
||||
} else if (dart is DateTime) {
|
||||
if (storeDateTimesAsText) {
|
||||
final encoded = mapToSqlVariable(dart, dialect).toString();
|
||||
final encoded = mapToSqlVariable(dart).toString();
|
||||
return "'$encoded'";
|
||||
} else {
|
||||
return (dart.millisecondsSinceEpoch ~/ 1000).toString();
|
||||
|
@ -125,17 +122,13 @@ class SqlTypes {
|
|||
}
|
||||
|
||||
/// Maps a raw [sqlValue] to Dart given its sql [type].
|
||||
T? read<T extends Object>(
|
||||
DriftSqlType<T> type,
|
||||
Object? sqlValue, [
|
||||
SqlDialect dialect = SqlDialect.sqlite,
|
||||
]) {
|
||||
T? read<T extends Object>(DriftSqlType<T> type, Object? sqlValue) {
|
||||
if (sqlValue == null) return null;
|
||||
|
||||
// ignore: unnecessary_cast
|
||||
switch (type as DriftSqlType<Object>) {
|
||||
case DriftSqlType.bool:
|
||||
if (dialect == SqlDialect.sqlite) {
|
||||
if (_dialect == SqlDialect.sqlite) {
|
||||
return (sqlValue != 0) as T;
|
||||
} else {
|
||||
return sqlValue as T;
|
||||
|
@ -258,7 +251,7 @@ enum DriftSqlType<T extends Object> implements _InternalDriftSqlType<T> {
|
|||
case DriftSqlType.int:
|
||||
return dialect == SqlDialect.sqlite ? 'INTEGER' : 'bigint';
|
||||
case DriftSqlType.dateTime:
|
||||
if (context.options.types.storeDateTimesAsText) {
|
||||
if (context.typeMapping.storeDateTimesAsText) {
|
||||
return dialect == SqlDialect.sqlite ? 'TEXT' : 'text';
|
||||
} else {
|
||||
return dialect == SqlDialect.sqlite ? 'INTEGER' : 'bigint';
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:test/test.dart';
|
|||
|
||||
void main() {
|
||||
test('maps without transformation', () {
|
||||
final types = const DriftDatabaseOptions().types;
|
||||
const types = SqlTypes(false);
|
||||
final data = Uint8List.fromList(List.generate(256, (i) => i));
|
||||
|
||||
expect(types.mapToSqlVariable(data), data);
|
||||
|
@ -13,7 +13,7 @@ void main() {
|
|||
});
|
||||
|
||||
test('writes blob literals', () {
|
||||
final types = const DriftDatabaseOptions().types;
|
||||
const types = SqlTypes(false);
|
||||
const hex = '67656E6572616C206B656E6F626921';
|
||||
final data = Uint8List.fromList(utf8.encode('general kenobi!'));
|
||||
|
||||
|
@ -23,7 +23,7 @@ void main() {
|
|||
test('maps of string', () {
|
||||
const chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz';
|
||||
|
||||
final types = const DriftDatabaseOptions().types;
|
||||
const types = SqlTypes(false);
|
||||
final data = List.generate(256, (i) => chars[i % chars.length]);
|
||||
final dataString = data.join();
|
||||
final dataInt = data.map((e) => e.codeUnits[0]).toList();
|
||||
|
|
|
@ -2,39 +2,40 @@ import 'package:drift/drift.dart';
|
|||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
final typeSystem = DriftDatabaseOptions().types;
|
||||
final sqliteTypes =
|
||||
DriftDatabaseOptions().createTypeMapping(SqlDialect.sqlite);
|
||||
final postgresTypes =
|
||||
DriftDatabaseOptions().createTypeMapping(SqlDialect.postgres);
|
||||
|
||||
group('bool type', () {
|
||||
test('Can read booleans from sqlite', () {
|
||||
expect(typeSystem.read(DriftSqlType.bool, 1, SqlDialect.sqlite), true);
|
||||
expect(typeSystem.read(DriftSqlType.bool, 0, SqlDialect.sqlite), false);
|
||||
expect(sqliteTypes.read(DriftSqlType.bool, 1), true);
|
||||
expect(sqliteTypes.read(DriftSqlType.bool, 0), false);
|
||||
});
|
||||
|
||||
test('Can read booleans from postgres', () {
|
||||
expect(
|
||||
typeSystem.read(DriftSqlType.bool, true, SqlDialect.postgres), true);
|
||||
expect(typeSystem.read(DriftSqlType.bool, false, SqlDialect.postgres),
|
||||
false);
|
||||
expect(postgresTypes.read(DriftSqlType.bool, true), true);
|
||||
expect(postgresTypes.read(DriftSqlType.bool, false), false);
|
||||
});
|
||||
|
||||
test('Can be mapped to sqlite constant', () {
|
||||
expect(typeSystem.mapToSqlLiteral(true, SqlDialect.sqlite), '1');
|
||||
expect(typeSystem.mapToSqlLiteral(false, SqlDialect.sqlite), '0');
|
||||
expect(sqliteTypes.mapToSqlLiteral(true), '1');
|
||||
expect(sqliteTypes.mapToSqlLiteral(false), '0');
|
||||
});
|
||||
|
||||
test('Can be mapped to postgres constant', () {
|
||||
expect(typeSystem.mapToSqlLiteral(true, SqlDialect.postgres), 'true');
|
||||
expect(typeSystem.mapToSqlLiteral(false, SqlDialect.postgres), 'false');
|
||||
expect(postgresTypes.mapToSqlLiteral(true), 'true');
|
||||
expect(postgresTypes.mapToSqlLiteral(false), 'false');
|
||||
});
|
||||
|
||||
test('Can be mapped to sqlite variable', () {
|
||||
expect(typeSystem.mapToSqlVariable(true, SqlDialect.sqlite), 1);
|
||||
expect(typeSystem.mapToSqlVariable(false, SqlDialect.sqlite), 0);
|
||||
expect(sqliteTypes.mapToSqlVariable(true), 1);
|
||||
expect(sqliteTypes.mapToSqlVariable(false), 0);
|
||||
});
|
||||
|
||||
test('Can be mapped to postgres variable', () {
|
||||
expect(typeSystem.mapToSqlVariable(true, SqlDialect.postgres), true);
|
||||
expect(typeSystem.mapToSqlVariable(false, SqlDialect.postgres), false);
|
||||
expect(postgresTypes.mapToSqlVariable(true), true);
|
||||
expect(postgresTypes.mapToSqlVariable(false), false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ import 'package:drift/drift.dart' as drift;
|
|||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
final typeSystem = const drift.DriftDatabaseOptions().types;
|
||||
final typeSystem = const drift.DriftDatabaseOptions()
|
||||
.createTypeMapping(drift.SqlDialect.sqlite);
|
||||
|
||||
group('RealType', () {
|
||||
test('can be read from floating point values returned by sql', () {
|
||||
|
|
|
@ -3,11 +3,11 @@ import 'package:test/test.dart';
|
|||
|
||||
void main() {
|
||||
test('types map null values to null', () {
|
||||
const options = DriftDatabaseOptions();
|
||||
expect(options.types.mapToSqlVariable(null), isNull);
|
||||
const mapping = SqlTypes(false);
|
||||
expect(mapping.mapToSqlVariable(null), isNull);
|
||||
|
||||
for (final type in DriftSqlType.values) {
|
||||
expect(options.types.read(type, null), isNull,
|
||||
expect(mapping.read(type, null), isNull,
|
||||
reason: '$type should map null response to null value');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -260,22 +260,15 @@ class ConfigTable extends Table with TableInfo<ConfigTable, Config> {
|
|||
Config map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Config(
|
||||
configKey: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}config_key'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
configValue: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}config_value'],
|
||||
attachedDatabase.executor.dialect),
|
||||
syncState: ConfigTable.$converter0n.fromSql(attachedDatabase.options.types
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}sync_state'],
|
||||
attachedDatabase.executor.dialect)),
|
||||
configKey: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}config_key'])!,
|
||||
configValue: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}config_value']),
|
||||
syncState: ConfigTable.$converter0n.fromSql(attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}sync_state'])),
|
||||
syncStateImplicit: ConfigTable.$converter1n.fromSql(
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}sync_state_implicit'],
|
||||
attachedDatabase.executor.dialect)),
|
||||
attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.int, data['${effectivePrefix}sync_state_implicit'])),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -460,10 +453,10 @@ class WithDefaults extends Table with TableInfo<WithDefaults, WithDefault> {
|
|||
WithDefault map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return WithDefault(
|
||||
a: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}a'], attachedDatabase.executor.dialect),
|
||||
b: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}b'], attachedDatabase.executor.dialect),
|
||||
a: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}a']),
|
||||
b: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}b']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -553,10 +546,8 @@ class NoIds extends Table with TableInfo<NoIds, NoIdRow> {
|
|||
NoIdRow map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return NoIdRow(
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.blob,
|
||||
data['${effectivePrefix}payload'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.blob, data['${effectivePrefix}payload'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -767,12 +758,12 @@ class WithConstraints extends Table
|
|||
WithConstraint map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return WithConstraint(
|
||||
a: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}a'], attachedDatabase.executor.dialect),
|
||||
b: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}b'], attachedDatabase.executor.dialect)!,
|
||||
c: attachedDatabase.options.types.read(DriftSqlType.double,
|
||||
data['${effectivePrefix}c'], attachedDatabase.executor.dialect),
|
||||
a: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}a']),
|
||||
b: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}b'])!,
|
||||
c: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.double, data['${effectivePrefix}c']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1030,20 +1021,14 @@ class Mytable extends Table with TableInfo<Mytable, MytableData> {
|
|||
MytableData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return MytableData(
|
||||
someid: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}someid'], attachedDatabase.executor.dialect)!,
|
||||
sometext: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}sometext'],
|
||||
attachedDatabase.executor.dialect),
|
||||
isInserting: attachedDatabase.options.types.read(
|
||||
DriftSqlType.bool,
|
||||
data['${effectivePrefix}is_inserting'],
|
||||
attachedDatabase.executor.dialect),
|
||||
somedate: attachedDatabase.options.types.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}somedate'],
|
||||
attachedDatabase.executor.dialect),
|
||||
someid: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}someid'])!,
|
||||
sometext: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}sometext']),
|
||||
isInserting: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.bool, data['${effectivePrefix}is_inserting']),
|
||||
somedate: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}somedate']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1254,12 +1239,12 @@ class Email extends Table
|
|||
EMail map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return EMail(
|
||||
sender: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}sender'], attachedDatabase.executor.dialect)!,
|
||||
title: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}title'], attachedDatabase.executor.dialect)!,
|
||||
body: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}body'], attachedDatabase.executor.dialect)!,
|
||||
sender: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}sender'])!,
|
||||
title: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
||||
body: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}body'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1439,10 +1424,10 @@ class WeirdTable extends Table with TableInfo<WeirdTable, WeirdData> {
|
|||
WeirdData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return WeirdData(
|
||||
sqlClass: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}class'], attachedDatabase.executor.dialect)!,
|
||||
textColumn: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}text'], attachedDatabase.executor.dialect)!,
|
||||
sqlClass: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}class'])!,
|
||||
textColumn: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}text'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1550,22 +1535,15 @@ class MyView extends ViewInfo<MyView, MyViewData> implements HasResultSet {
|
|||
MyViewData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return MyViewData(
|
||||
configKey: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}config_key'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
configValue: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}config_value'],
|
||||
attachedDatabase.executor.dialect),
|
||||
syncState: ConfigTable.$converter0n.fromSql(attachedDatabase.options.types
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}sync_state'],
|
||||
attachedDatabase.executor.dialect)),
|
||||
configKey: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}config_key'])!,
|
||||
configValue: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}config_value']),
|
||||
syncState: ConfigTable.$converter0n.fromSql(attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}sync_state'])),
|
||||
syncStateImplicit: ConfigTable.$converter1n.fromSql(
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}sync_state_implicit'],
|
||||
attachedDatabase.executor.dialect)),
|
||||
attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.int, data['${effectivePrefix}sync_state_implicit'])),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -241,19 +241,16 @@ class $CategoriesTable extends Categories
|
|||
Category map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Category(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
description: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}desc'], attachedDatabase.executor.dialect)!,
|
||||
priority: $CategoriesTable.$converter0.fromSql(
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}priority'],
|
||||
attachedDatabase.executor.dialect)!),
|
||||
descriptionInUpperCase: attachedDatabase.options.types.read(
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
description: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}desc'])!,
|
||||
priority: $CategoriesTable.$converter0.fromSql(attachedDatabase
|
||||
.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}priority'])!),
|
||||
descriptionInUpperCase: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}description_in_upper_case'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
data['${effectivePrefix}description_in_upper_case'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -553,22 +550,16 @@ class $TodosTableTable extends TodosTable
|
|||
TodoEntry map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return TodoEntry(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
title: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}title'], attachedDatabase.executor.dialect),
|
||||
content: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}content'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
targetDate: attachedDatabase.options.types.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}target_date'],
|
||||
attachedDatabase.executor.dialect),
|
||||
category: attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}category'],
|
||||
attachedDatabase.executor.dialect),
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
title: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}title']),
|
||||
content: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
|
||||
targetDate: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}target_date']),
|
||||
category: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}category']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -862,22 +853,16 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|||
User map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return User(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
name: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}name'], attachedDatabase.executor.dialect)!,
|
||||
isAwesome: attachedDatabase.options.types.read(
|
||||
DriftSqlType.bool,
|
||||
data['${effectivePrefix}is_awesome'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
profilePicture: attachedDatabase.options.types.read(
|
||||
DriftSqlType.blob,
|
||||
data['${effectivePrefix}profile_picture'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
creationTime: attachedDatabase.options.types.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}creation_time'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
name: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||
isAwesome: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.bool, data['${effectivePrefix}is_awesome'])!,
|
||||
profilePicture: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.blob, data['${effectivePrefix}profile_picture'])!,
|
||||
creationTime: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.dateTime, data['${effectivePrefix}creation_time'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1050,10 +1035,10 @@ class $SharedTodosTable extends SharedTodos
|
|||
SharedTodo map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return SharedTodo(
|
||||
todo: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}todo'], attachedDatabase.executor.dialect)!,
|
||||
user: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}user'], attachedDatabase.executor.dialect)!,
|
||||
todo: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}todo'])!,
|
||||
user: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}user'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1233,23 +1218,15 @@ class $TableWithoutPKTable extends TableWithoutPK
|
|||
CustomRowClass map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return CustomRowClass.map(
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}not_really_an_id'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.double,
|
||||
data['${effectivePrefix}some_float'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
custom: $TableWithoutPKTable.$converter0.fromSql(
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}custom'],
|
||||
attachedDatabase.executor.dialect)!),
|
||||
webSafeInt: attachedDatabase.options.types.read(
|
||||
DriftSqlType.bigInt,
|
||||
data['${effectivePrefix}web_safe_int'],
|
||||
attachedDatabase.executor.dialect),
|
||||
attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}not_really_an_id'])!,
|
||||
attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.double, data['${effectivePrefix}some_float'])!,
|
||||
custom: $TableWithoutPKTable.$converter0.fromSql(attachedDatabase
|
||||
.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}custom'])!),
|
||||
webSafeInt: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.bigInt, data['${effectivePrefix}web_safe_int']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1396,11 +1373,8 @@ class $PureDefaultsTable extends PureDefaults
|
|||
PureDefault map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return PureDefault(
|
||||
txt: $PureDefaultsTable.$converter0n.fromSql(
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}insert'],
|
||||
attachedDatabase.executor.dialect)),
|
||||
txt: $PureDefaultsTable.$converter0n.fromSql(attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}insert'])),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1492,14 +1466,10 @@ class $CategoryTodoCountViewView
|
|||
{String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return CategoryTodoCountViewData(
|
||||
description: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}description'],
|
||||
attachedDatabase.executor.dialect),
|
||||
itemCount: attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}item_count'],
|
||||
attachedDatabase.executor.dialect),
|
||||
description: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}description']),
|
||||
itemCount: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}item_count']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1602,10 +1572,10 @@ class $TodoWithCategoryViewView
|
|||
{String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return TodoWithCategoryViewData(
|
||||
title: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}title'], attachedDatabase.executor.dialect),
|
||||
description: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}desc'], attachedDatabase.executor.dialect)!,
|
||||
title: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}title']),
|
||||
description: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}desc'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -347,8 +347,7 @@ class RowMappingWriter {
|
|||
final rawData = "data['\${effectivePrefix}$columnName']";
|
||||
|
||||
final sqlType = column.type.toString();
|
||||
var loadType =
|
||||
'$databaseGetter.options.types.read($sqlType, $rawData, $databaseGetter.executor.dialect)';
|
||||
var loadType = '$databaseGetter.typeMapping.read($sqlType, $rawData)';
|
||||
|
||||
if (!column.nullable) {
|
||||
loadType += '!';
|
||||
|
|
|
@ -27,3 +27,7 @@ dev_dependencies:
|
|||
flutter:
|
||||
assets:
|
||||
- test_asset.db
|
||||
|
||||
dependency_overrides:
|
||||
# Flutter's test packages don't support the latest analyzer yet.
|
||||
test_api: ^0.4.16
|
||||
|
|
|
@ -196,13 +196,12 @@ class $CategoriesTable extends Categories
|
|||
Category map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Category(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
name: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}name'], attachedDatabase.executor.dialect)!,
|
||||
color: $CategoriesTable.$converter0.fromSql(attachedDatabase.options.types
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}color'],
|
||||
attachedDatabase.executor.dialect)!),
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
name: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||
color: $CategoriesTable.$converter0.fromSql(attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}color'])!),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -453,20 +452,14 @@ class $TodoEntriesTable extends TodoEntries
|
|||
TodoEntry map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return TodoEntry(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
description: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}description'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
category: attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}category'],
|
||||
attachedDatabase.executor.dialect),
|
||||
dueDate: attachedDatabase.options.types.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}due_date'],
|
||||
attachedDatabase.executor.dialect),
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
description: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}description'])!,
|
||||
category: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}category']),
|
||||
dueDate: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}due_date']),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -609,10 +602,8 @@ class TextEntries extends Table
|
|||
TextEntrie map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return TextEntrie(
|
||||
description: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}description'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
description: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}description'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,3 +38,7 @@ dev_dependencies:
|
|||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
dependency_overrides:
|
||||
# Flutter's test packages don't support the latest analyzer yet.
|
||||
test_api: ^0.4.16
|
||||
|
|
|
@ -162,12 +162,10 @@ class $NotesTable extends Notes with TableInfo<$NotesTable, Note> {
|
|||
Note map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Note(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
content: attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}content'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
content: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
sqlcipher_flutter_libs
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
|
|
@ -24,3 +24,7 @@ dev_dependencies:
|
|||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
dependency_overrides:
|
||||
# Flutter's test packages don't support the latest analyzer yet.
|
||||
test_api: ^0.4.16
|
||||
|
|
|
@ -6,7 +6,6 @@ list(APPEND FLUTTER_PLUGIN_LIST
|
|||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
sqlcipher_flutter_libs
|
||||
)
|
||||
|
||||
set(PLUGIN_BUNDLED_LIBRARIES)
|
||||
|
|
|
@ -160,10 +160,10 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
|
|||
Entrie map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Entrie(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
value: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}text'], attachedDatabase.executor.dialect)!,
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
value: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}text'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,3 +16,7 @@ dev_dependencies:
|
|||
build_web_compilers: ^3.2.1
|
||||
flutter_lints: ^1.0.4
|
||||
drift_dev:
|
||||
|
||||
dependency_overrides:
|
||||
# Flutter's test packages don't support the latest analyzer yet.
|
||||
test_api: ^0.4.16
|
||||
|
|
|
@ -181,7 +181,9 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|||
'id', aliasedName, false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: false,
|
||||
defaultConstraints: 'PRIMARY KEY AUTOINCREMENT');
|
||||
defaultConstraints:
|
||||
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'),
|
||||
hasAutoIncrement: true);
|
||||
final VerificationMeta _nameMeta = const VerificationMeta('name');
|
||||
@override
|
||||
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
||||
|
@ -200,7 +202,8 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|||
'next_user', aliasedName, true,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: false,
|
||||
defaultConstraints: 'REFERENCES "users" ("id")');
|
||||
defaultConstraints:
|
||||
GeneratedColumn.constraintIsAlways('REFERENCES "users" ("id")'));
|
||||
@override
|
||||
List<GeneratedColumn> get $columns => [id, name, birthday, nextUser];
|
||||
@override
|
||||
|
@ -240,13 +243,13 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|||
User map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return User(
|
||||
id: attachedDatabase.options.types
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
name: attachedDatabase.options.types
|
||||
name: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||
birthday: attachedDatabase.options.types
|
||||
birthday: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
|
||||
nextUser: attachedDatabase.options.types
|
||||
nextUser: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
|
||||
);
|
||||
}
|
||||
|
@ -489,13 +492,13 @@ class Groups extends Table with TableInfo<Groups, Group> {
|
|||
Group map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Group(
|
||||
id: attachedDatabase.options.types
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
title: attachedDatabase.options.types
|
||||
title: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
||||
deleted: attachedDatabase.options.types
|
||||
deleted: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.bool, data['${effectivePrefix}deleted']),
|
||||
owner: attachedDatabase.options.types
|
||||
owner: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}owner'])!,
|
||||
);
|
||||
}
|
||||
|
@ -709,11 +712,11 @@ class Notes extends Table
|
|||
Note map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Note(
|
||||
title: attachedDatabase.options.types
|
||||
title: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
||||
content: attachedDatabase.options.types
|
||||
content: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}content'])!,
|
||||
searchTerms: attachedDatabase.options.types
|
||||
searchTerms: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}search_terms'])!,
|
||||
);
|
||||
}
|
||||
|
@ -825,15 +828,15 @@ class GroupCount extends ViewInfo<GroupCount, GroupCountData>
|
|||
GroupCountData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return GroupCountData(
|
||||
id: attachedDatabase.options.types
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
name: attachedDatabase.options.types
|
||||
name: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||
birthday: attachedDatabase.options.types
|
||||
birthday: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}birthday']),
|
||||
nextUser: attachedDatabase.options.types
|
||||
nextUser: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}next_user']),
|
||||
groupCount: attachedDatabase.options.types
|
||||
groupCount: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}group_count'])!,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -160,9 +160,9 @@ class Entries extends Table with TableInfo<Entries, Entrie> {
|
|||
Entrie map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Entrie(
|
||||
id: attachedDatabase.options.types
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
value: attachedDatabase.options.types
|
||||
value: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}text'])!,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -124,7 +124,8 @@ class Users extends Table with TableInfo<Users, User> {
|
|||
'id', aliasedName, false,
|
||||
type: DriftSqlType.int,
|
||||
requiredDuringInsert: false,
|
||||
$customConstraints: 'NOT NULL PRIMARY KEY AUTOINCREMENT');
|
||||
$customConstraints: 'NOT NULL PRIMARY KEY AUTOINCREMENT',
|
||||
hasAutoIncrement: true);
|
||||
final VerificationMeta _nameMeta = const VerificationMeta('name');
|
||||
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
||||
'name', aliasedName, false,
|
||||
|
@ -160,9 +161,9 @@ class Users extends Table with TableInfo<Users, User> {
|
|||
User map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return User(
|
||||
id: attachedDatabase.options.types
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
name: attachedDatabase.options.types
|
||||
name: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -163,10 +163,10 @@ class $KeyValuesTable extends KeyValues
|
|||
KeyValue map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return KeyValue(
|
||||
key: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}key'], attachedDatabase.executor.dialect)!,
|
||||
value: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}value'], attachedDatabase.executor.dialect)!,
|
||||
key: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}key'])!,
|
||||
value: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}value'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,11 @@ version: 1.0.0
|
|||
|
||||
environment:
|
||||
sdk: '>=2.12.0-0 <3.0.0'
|
||||
flutter: ^3.0.0
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
drift: ^2.0.0
|
||||
path: ^1.8.1
|
||||
sqflite_sqlcipher: ^2.0.0
|
||||
|
@ -13,8 +16,6 @@ dependencies:
|
|||
dev_dependencies:
|
||||
drift_testcases:
|
||||
path: ../integration_tests/drift_testcases
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_lints: ^2.0.1
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
@ -22,5 +23,5 @@ dev_dependencies:
|
|||
sdk: flutter
|
||||
|
||||
dependency_overrides:
|
||||
drift:
|
||||
path: ../../drift
|
||||
# Flutter's test packages don't support the latest analyzer yet.
|
||||
test_api: ^0.4.16
|
||||
|
|
|
@ -289,23 +289,16 @@ class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|||
User map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return User(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
name: attachedDatabase.options.types.read(DriftSqlType.string,
|
||||
data['${effectivePrefix}name'], attachedDatabase.executor.dialect)!,
|
||||
birthDate: attachedDatabase.options.types.read(
|
||||
DriftSqlType.dateTime,
|
||||
data['${effectivePrefix}birth_date'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
profilePicture: attachedDatabase.options.types.read(
|
||||
DriftSqlType.blob,
|
||||
data['${effectivePrefix}profile_picture'],
|
||||
attachedDatabase.executor.dialect),
|
||||
preferences: $UsersTable.$converter0.fromSql(
|
||||
attachedDatabase.options.types.read(
|
||||
DriftSqlType.string,
|
||||
data['${effectivePrefix}preferences'],
|
||||
attachedDatabase.executor.dialect)),
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
name: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
||||
birthDate: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.dateTime, data['${effectivePrefix}birth_date'])!,
|
||||
profilePicture: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.blob, data['${effectivePrefix}profile_picture']),
|
||||
preferences: $UsersTable.$converter0.fromSql(attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.string, data['${effectivePrefix}preferences'])),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -529,18 +522,12 @@ class $FriendshipsTable extends Friendships
|
|||
Friendship map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Friendship(
|
||||
firstUser: attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}first_user'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
secondUser: attachedDatabase.options.types.read(
|
||||
DriftSqlType.int,
|
||||
data['${effectivePrefix}second_user'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
reallyGoodFriends: attachedDatabase.options.types.read(
|
||||
DriftSqlType.bool,
|
||||
data['${effectivePrefix}really_good_friends'],
|
||||
attachedDatabase.executor.dialect)!,
|
||||
firstUser: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}first_user'])!,
|
||||
secondUser: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}second_user'])!,
|
||||
reallyGoodFriends: attachedDatabase.typeMapping.read(
|
||||
DriftSqlType.bool, data['${effectivePrefix}really_good_friends'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,18 +9,10 @@ environment:
|
|||
dependencies:
|
||||
drift: ^2.0.0-0
|
||||
json_annotation: ^4.5.0
|
||||
test: ^1.16.0
|
||||
test: ^1.22.0
|
||||
|
||||
dev_dependencies:
|
||||
build_runner: ^2.1.11
|
||||
drift_dev: ^2.0.0
|
||||
json_serializable: ^6.2.0
|
||||
lints: ^2.0.0
|
||||
|
||||
dependency_overrides:
|
||||
drift:
|
||||
path: ../../../drift
|
||||
drift_dev:
|
||||
path: ../../../drift_dev
|
||||
sqlparser:
|
||||
path: ../../../sqlparser
|
||||
|
|
|
@ -133,8 +133,8 @@ class $FoosTable extends Foos with TableInfo<$FoosTable, Foo> {
|
|||
Foo map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Foo(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -270,8 +270,8 @@ class $BarsTable extends Bars with TableInfo<$BarsTable, Bar> {
|
|||
Bar map(Map<String, dynamic> data, {String? tablePrefix}) {
|
||||
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
||||
return Bar(
|
||||
id: attachedDatabase.options.types.read(DriftSqlType.int,
|
||||
data['${effectivePrefix}id'], attachedDatabase.executor.dialect)!,
|
||||
id: attachedDatabase.typeMapping
|
||||
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue