mirror of https://github.com/AMT-Cheif/drift.git
Fix warnings (2.6-dev SDK), escape \r, constant workaround
This commit is contained in:
parent
6e32e37dd7
commit
5510a90583
|
@ -4,7 +4,8 @@
|
|||
to check values for both an upper and lower bound
|
||||
- Automatically map `BOOLEAN` and `DATETIME` columns declared in a sql file to the appropriate type
|
||||
(both used to be `double` before).
|
||||
- __Breaking__: Remove the type parameter from `Insertable.createCompanion`.
|
||||
- __Breaking__: Remove the type parameter from `Insertable.createCompanion` (it was declared as an
|
||||
internal method)
|
||||
|
||||
## 2.0.0
|
||||
This is the first major update after the initial release and moor and we have a lot to cover:
|
||||
|
|
|
@ -831,7 +831,7 @@ class $IngredientInRecipesTable extends IngredientInRecipes
|
|||
}
|
||||
|
||||
abstract class _$Database extends GeneratedDatabase {
|
||||
_$Database(QueryExecutor e) : super(const SqlTypeSystem.withDefaults(), e);
|
||||
_$Database(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e);
|
||||
$CategoriesTable _categories;
|
||||
$CategoriesTable get categories => _categories ??= $CategoriesTable(this);
|
||||
$RecipesTable _recipes;
|
||||
|
|
|
@ -24,7 +24,7 @@ class _CreateEntryBarState extends State<CreateEntryBar> {
|
|||
child: TextField(
|
||||
controller: _controller,
|
||||
onSubmitted: (_) => _submit(),
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
),
|
||||
|
|
|
@ -45,7 +45,7 @@ class _EntryCard extends StatelessWidget {
|
|||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(entry.content),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
Checkbox(
|
||||
value: entry.done,
|
||||
onChanged: (checked) {
|
||||
|
|
|
@ -124,8 +124,8 @@ mixin QueryEngine on DatabaseConnectionUser {
|
|||
bool get topLevel => false;
|
||||
|
||||
/// We can detect when a user called methods on the wrong [QueryEngine]
|
||||
/// (e.g. calling [GeneratedDatabase.into] in a transaction, where
|
||||
/// [Transaction.into] should have been called instead). See the documentation
|
||||
/// (e.g. calling [QueryEngine.into] in a transaction, where
|
||||
/// [QueryEngine.into] should have been called instead). See the documentation
|
||||
/// of [topLevel] on how this works.
|
||||
QueryEngine get _resolvedEngine {
|
||||
if (!topLevel) {
|
||||
|
|
|
@ -8,7 +8,7 @@ import 'package:moor/src/runtime/structure/table_info.dart';
|
|||
/// A `DELETE` statement in sql
|
||||
class DeleteStatement<T extends Table, D extends DataClass> extends Query<T, D>
|
||||
with SingleTableQueryMixin<T, D> {
|
||||
/// This constructor should be called by [GeneratedDatabase.delete] for you.
|
||||
/// This constructor should be called by [QueryEngine.delete] for you.
|
||||
DeleteStatement(QueryEngine database, TableInfo<T, D> table)
|
||||
: super(database, table);
|
||||
|
||||
|
|
|
@ -223,8 +223,8 @@ class SimpleSelectStatement<T extends Table, D extends DataClass>
|
|||
/// See also:
|
||||
/// - [innerJoin], [leftOuterJoin] and [crossJoin], which can be used to
|
||||
/// construct a [Join].
|
||||
/// - [GeneratedDatabase.alias], which can be used to build statements that
|
||||
/// refer to the same table multiple times.
|
||||
/// - [DatabaseConnectionUser.alias], which can be used to build statements
|
||||
/// that refer to the same table multiple times.
|
||||
JoinedSelectStatement join(List<Join> joins) {
|
||||
final statement = JoinedSelectStatement(database, table, joins);
|
||||
|
||||
|
|
|
@ -20,6 +20,12 @@ class SqlTypeSystem {
|
|||
RealType(),
|
||||
]);
|
||||
|
||||
/// Constant field of [SqlTypeSystem.withDefaults()]. This field exists as a
|
||||
/// workaround for an analyzer bug: https://dartbug.com/38658
|
||||
///
|
||||
/// Used internally by generated code.
|
||||
static const defaultInstance = SqlTypeSystem.withDefaults();
|
||||
|
||||
/// Returns the appropriate sql type for the dart type provided as the
|
||||
/// generic parameter.
|
||||
SqlType<T> forDartType<T>() {
|
||||
|
|
|
@ -876,8 +876,7 @@ class Mytable extends Table with TableInfo<Mytable, MytableData> {
|
|||
}
|
||||
|
||||
abstract class _$CustomTablesDb extends GeneratedDatabase {
|
||||
_$CustomTablesDb(QueryExecutor e)
|
||||
: super(const SqlTypeSystem.withDefaults(), e);
|
||||
_$CustomTablesDb(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e);
|
||||
NoIds _noIds;
|
||||
NoIds get noIds => _noIds ??= NoIds(this);
|
||||
WithDefaults _withDefaults;
|
||||
|
|
|
@ -1286,7 +1286,7 @@ class $PureDefaultsTable extends PureDefaults
|
|||
}
|
||||
|
||||
abstract class _$TodoDb extends GeneratedDatabase {
|
||||
_$TodoDb(QueryExecutor e) : super(const SqlTypeSystem.withDefaults(), e);
|
||||
_$TodoDb(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e);
|
||||
$TodosTableTable _todosTable;
|
||||
$TodosTableTable get todosTable => _todosTable ??= $TodosTableTable(this);
|
||||
$CategoriesTable _categories;
|
||||
|
|
|
@ -47,7 +47,7 @@ void main() {
|
|||
setUp(() {
|
||||
executor = MockExecutor();
|
||||
queryExecutor = MockQueryExecutor();
|
||||
db = _FakeDb(const SqlTypeSystem.withDefaults(), executor);
|
||||
db = _FakeDb(SqlTypeSystem.defaultInstance, executor);
|
||||
});
|
||||
|
||||
test('onCreate', () async {
|
||||
|
|
|
@ -20,7 +20,7 @@ void main() {
|
|||
|
||||
expectedResults.forEach((key, value) {
|
||||
test('should extract field', () {
|
||||
final ctx = GenerationContext(const SqlTypeSystem.withDefaults(), null);
|
||||
final ctx = GenerationContext(SqlTypeSystem.defaultInstance, null);
|
||||
key(column).writeInto(ctx);
|
||||
|
||||
expect(ctx.sql, value);
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:test/test.dart';
|
|||
|
||||
void main() {
|
||||
test('types map null values to null', () {
|
||||
final typeSystem = const SqlTypeSystem.withDefaults();
|
||||
const typeSystem = SqlTypeSystem.defaultInstance;
|
||||
|
||||
for (var type in typeSystem.types) {
|
||||
expect(type.mapToSqlVariable(null), isNull,
|
||||
|
|
|
@ -27,7 +27,7 @@ class _AddCategoryDialogState extends State<AddCategoryDialog> {
|
|||
TextField(
|
||||
controller: _controller,
|
||||
autofocus: true,
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Name of the category',
|
||||
),
|
||||
onSubmitted: (_) => _addEntry(),
|
||||
|
|
|
@ -35,7 +35,7 @@ class CategoriesDrawer extends StatelessWidget {
|
|||
},
|
||||
),
|
||||
),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
|
@ -89,7 +89,7 @@ class _CategoryDrawerEntry extends StatelessWidget {
|
|||
// also show a delete button if the category can be deleted
|
||||
if (category != null) {
|
||||
rowContent.addAll([
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
color: Colors.red,
|
||||
|
|
|
@ -45,7 +45,7 @@ class _TodoEditDialogState extends State<TodoEditDialog> {
|
|||
children: [
|
||||
TextField(
|
||||
controller: textController,
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'What needs to be done?',
|
||||
helperText: 'Content of entry',
|
||||
),
|
||||
|
@ -53,7 +53,7 @@ class _TodoEditDialogState extends State<TodoEditDialog> {
|
|||
Row(
|
||||
children: <Widget>[
|
||||
Text(formattedDate),
|
||||
Spacer(),
|
||||
const Spacer(),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.calendar_today),
|
||||
onPressed: () async {
|
||||
|
|
|
@ -12,11 +12,11 @@ dependencies:
|
|||
intl:
|
||||
cupertino_icons: ^0.1.2
|
||||
rxdart: 0.21.0
|
||||
moor_flutter: ^1.4.0
|
||||
moor_flutter: ^2.0.0
|
||||
|
||||
dev_dependencies:
|
||||
build_runner:
|
||||
moor_generator: ^1.4.0
|
||||
moor_generator: ^2.0.0
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
## upcoming release
|
||||
|
||||
- Escape `\r` characters in generated Dart literals
|
||||
- Fix for [an analyzer bug on constant expressions](https://dartbug.com/38658) in generated code
|
||||
|
||||
## 1.7.1
|
||||
- Drop support for analyzer versions `<0.36.4`. They weren't supported in version 1.7.0 either, but
|
||||
the `pubspec.yaml` did not specify this correctly.
|
||||
|
|
|
@ -7,5 +7,6 @@ String escapeForDart(String value) {
|
|||
return value
|
||||
.replaceAll("'", "\\'")
|
||||
.replaceAll('\$', '\\\$')
|
||||
.replaceAll('\r', '\\r')
|
||||
.replaceAll('\n', '\\n');
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class DatabaseWriter {
|
|||
final className = '_\$${db.fromClass.name}';
|
||||
dbScope.leaf().write(
|
||||
'abstract class $className extends GeneratedDatabase {\n'
|
||||
'$className(QueryExecutor e) : super(const SqlTypeSystem.withDefaults(), e); \n');
|
||||
'$className(QueryExecutor e) : super(SqlTypeSystem.defaultInstance, e); \n');
|
||||
|
||||
final tableGetters = <String>[];
|
||||
|
||||
|
|
Loading…
Reference in New Issue