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