diff --git a/pubspec.yaml b/pubspec.yaml new file mode 100644 index 000000000..ec90635f7 --- /dev/null +++ b/pubspec.yaml @@ -0,0 +1,13 @@ +# This pubspec file exists so that this repository can show up in the generated list of community +# repositories. It's not meant to serve as an actual pub file. + +name: sally +description: Sally is a safe and reactive persistence library for Dart applications +homepage: https://github.com/simolus3/sally +authors: + - Flutter Community + - Simon Binder +maintainer: Simon Binder (@simolus3) + +environment: + sdk: '>=2.0.0 <3.0.0' diff --git a/sally/lib/diff_util.dart b/sally/lib/diff_util.dart index 4eb6aeeac..431c46d3e 100644 --- a/sally/lib/diff_util.dart +++ b/sally/lib/diff_util.dart @@ -6,21 +6,23 @@ library diff_util; import 'package:sally/src/utils/android_diffutils_port.dart' as impl; class EditAction { - /// The index of the first list on which this action should be applied. If /// this action [isDelete], that index and the next [amount] indices should be /// deleted. Otherwise, this index should be moved back by [amount] and /// entries from the second list (starting at [indexFromOther]) should be /// inserted into the gap. final int index; + /// The amount of entries affected by this action final int amount; + /// If this action [isInsert], this is the first index from the second list /// from where the items should be taken from. final int indexFromOther; /// Whether this action should delete entries from the first list bool get isDelete => indexFromOther == null; + /// Whether this action should insert entries into the first list bool get isInsert => indexFromOther != null; @@ -30,14 +32,13 @@ class EditAction { String toString() { if (isDelete) { return 'EditAction: Delete $amount entries from the first list, starting ' - 'at index $index'; + 'at index $index'; } else { return 'EditAction: Insert $amount entries into the first list, taking ' 'them from the second list starting at $indexFromOther. The entries ' - 'should be written starting at index $index'; + 'should be written starting at index $index'; } } - } /// Finds the shortest edit script that turns list [a] into list [b]. diff --git a/sally/lib/src/runtime/executor/executor.dart b/sally/lib/src/runtime/executor/executor.dart index f71d6aa6b..388a01550 100644 --- a/sally/lib/src/runtime/executor/executor.dart +++ b/sally/lib/src/runtime/executor/executor.dart @@ -76,14 +76,16 @@ abstract class GeneratedDatabase { /// Starts an [InsertStatement] for a given table. You can use that statement /// to write data into the [table] by using [InsertStatement.insert]. - @protected @visibleForTesting + @protected + @visibleForTesting InsertStatement into(TableInfo table) => InsertStatement(this, table); /// Starts an [UpdateStatement] for the given table. You can use that /// statement to update individual rows in that table by setting a where /// clause on that table and then use [UpdateStatement.write]. - @protected @visibleForTesting + @protected + @visibleForTesting UpdateStatement update( TableInfo table) => UpdateStatement(this, table); @@ -91,14 +93,16 @@ abstract class GeneratedDatabase { /// Starts a query on the given table. Queries can be limited with an limit /// or a where clause and can either return a current snapshot or a continuous /// stream of data - @protected @visibleForTesting + @protected + @visibleForTesting SelectStatement select( TableInfo table) { return SelectStatement(this, table); } /// Starts a [DeleteStatement] that can be used to delete rows from a table. - @protected @visibleForTesting + @protected + @visibleForTesting DeleteStatement delete
(TableInfo table) => DeleteStatement
(this, table); } diff --git a/sally/lib/src/utils/android_diffutils_port.dart b/sally/lib/src/utils/android_diffutils_port.dart index 5c2aa80dd..5e2d5d89b 100644 --- a/sally/lib/src/utils/android_diffutils_port.dart +++ b/sally/lib/src/utils/android_diffutils_port.dart @@ -122,12 +122,14 @@ List calculateDiff(DiffInput input) { final first = snakes.isEmpty ? null : snakes.first; if (first == null || first.x != 0 || first.y != 0) { - snakes.insert(0, Snake() - ..x = 0 - ..y = 0 - ..removal = false - ..size = 0 - ..reverse = false); + snakes.insert( + 0, + Snake() + ..x = 0 + ..y = 0 + ..removal = false + ..size = 0 + ..reverse = false); } return snakes; @@ -239,5 +241,5 @@ Snake _diffPartial(DiffInput input, int startOld, int endOld, int startNew, } throw StateError("Unexpected case: Please make sure the lists don't change " - 'during a diff'); + 'during a diff'); } diff --git a/sally/test/diff_util_test.dart b/sally/test/diff_util_test.dart index 89faf0d23..7821fc80f 100644 --- a/sally/test/diff_util_test.dart +++ b/sally/test/diff_util_test.dart @@ -9,7 +9,8 @@ List applyEditScript(List a, List b, List actions) { final deleteStartIndex = action.index; copy.removeRange(deleteStartIndex, deleteStartIndex + action.amount); } else { - final toAdd = b.getRange(action.indexFromOther, action.indexFromOther + action.amount); + final toAdd = b.getRange( + action.indexFromOther, action.indexFromOther + action.amount); copy.insertAll(action.index, toAdd); } } @@ -18,10 +19,10 @@ List applyEditScript(List a, List b, List actions) { } void main() { - final a = ['a', 'b', 'c', 'a', 'b', 'b', 'a']; + final a = ['a', 'b', 'c', 'a', 'b', 'b', 'a']; final b = ['c', 'b', 'a', 'b', 'a', 'c']; test('diff matcher should produce a correct edit script', () { expect(applyEditScript(a, b, diff(a, b)), b); }); -} \ No newline at end of file +} diff --git a/sally_flutter/README.md b/sally_flutter/README.md index ac9e834bd..6bf9a3da1 100644 --- a/sally_flutter/README.md +++ b/sally_flutter/README.md @@ -260,4 +260,4 @@ Implementing this will very likely result in backwards-incompatible changes. accessible for the generated code - `GROUP BY` grouping functions - Support for different database engines - - Support webapps via `AlaSQL` or a different engine \ No newline at end of file + - Support webapps via `AlaSQL` or a different engine