Rename project to "moor"

This commit is contained in:
Simon Binder 2019-03-09 16:37:22 +01:00
parent 532dc23944
commit 62900a93a9
No known key found for this signature in database
GPG Key ID: B807FDF954BA00CF
164 changed files with 343 additions and 374 deletions

View File

6
moor/README.md Normal file
View File

@ -0,0 +1,6 @@
# moor
This library defines the APIs for the moor persistence library. When using the library,
you'll probably want to use the moor_flutter implementation directly.
Please see the homepage of [moor](https://github.com/simolus3/moor) for details.

View File

@ -1,4 +1,4 @@
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
part 'example.g.dart';
@ -37,7 +37,7 @@ class IngredientInRecipes extends Table {
IntColumn get amountInGrams => integer().named('amount')();
}
@UseSally(tables: [Categories, Recipes, Ingredients, IngredientInRecipes])
@Usemoor(tables: [Categories, Recipes, Ingredients, IngredientInRecipes])
class Database extends _$Database {
Database(QueryExecutor e) : super(e);

View File

@ -3,7 +3,7 @@
part of 'example.dart';
// **************************************************************************
// SallyGenerator
// moorGenerator
// **************************************************************************
class Category {

View File

@ -3,7 +3,7 @@
/// list that can be updated.
library diff_util;
import 'package:sally/src/utils/android_diffutils_port.dart' as impl;
import 'package:moor/src/utils/android_diffutils_port.dart' as impl;
class EditAction {
/// The index of the first list on which this action should be applied. If

21
moor/lib/moor.dart Normal file
View File

@ -0,0 +1,21 @@
library moor;
export 'package:moor/src/dsl/table.dart';
export 'package:moor/src/dsl/columns.dart';
export 'package:moor/src/dsl/database.dart';
export 'package:moor/src/runtime/components/order_by.dart';
export 'package:moor/src/runtime/executor/executor.dart';
export 'package:moor/src/types/type_system.dart';
export 'package:moor/src/runtime/expressions/comparable.dart';
export 'package:moor/src/runtime/expressions/user_api.dart';
export 'package:moor/src/runtime/statements/query.dart';
export 'package:moor/src/runtime/statements/select.dart';
export 'package:moor/src/runtime/statements/insert.dart';
export 'package:moor/src/runtime/statements/delete.dart';
export 'package:moor/src/runtime/structure/columns.dart';
export 'package:moor/src/runtime/structure/table_info.dart';
export 'package:moor/src/runtime/database.dart';
export 'package:moor/src/types/sql_types.dart';
export 'package:moor/src/runtime/migration.dart';
export 'package:moor/src/runtime/exceptions.dart';

View File

@ -1,8 +1,8 @@
// todo more datatypes (at least binary blobs)
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:sally/src/runtime/expressions/comparable.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:moor/src/runtime/expressions/comparable.dart';
import 'package:moor/src/types/sql_types.dart';
abstract class Column<T, S extends SqlType<T>> extends Expression<T, S> {}
@ -27,7 +27,7 @@ abstract class DateTimeColumn extends Column<DateTime, DateTimeType> {}
/// A column builder is used to specify which columns should appear in a table.
/// All of the methods defined in this class and its subclasses are not meant to
/// be called at runtime. Instead, sally_generator will take a look at your
/// be called at runtime. Instead, moor_generator will take a look at your
/// source code (specifically, it will analyze which of the methods you use) to
/// figure out the column structure of a table.
class ColumnBuilder<Builder, ResultColumn> {
@ -45,7 +45,7 @@ class ColumnBuilder<Builder, ResultColumn> {
Builder nullable() => null;
/// Turns this column builder into a column. This method won't actually be
/// called in your code. Instead, sally_generator will take a look at your
/// called in your code. Instead, moor_generator will take a look at your
/// source code to figure out your table structure.
ResultColumn call() => null;
}

View File

@ -1,9 +1,9 @@
import 'package:meta/meta.dart';
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
/// Use this class as an annotation to inform sally_generator that a database
/// class should be generated using the specified [UseSally.tables].
class UseSally {
/// Use this class as an annotation to inform moor_generator that a database
/// class should be generated using the specified [Usemoor.tables].
class Usemoor {
/// The tables to include in the database
final List<Type> tables;
@ -12,9 +12,9 @@ class UseSally {
/// database logic into smaller components.
final List<Type> daos;
/// Use this class as an annotation to inform sally_generator that a database
/// class should be generated using the specified [UseSally.tables].
const UseSally({@required this.tables, this.daos = const []});
/// Use this class as an annotation to inform moor_generator that a database
/// class should be generated using the specified [Usemoor.tables].
const Usemoor({@required this.tables, this.daos = const []});
}
/// Annotation to use on classes that implement [DatabaseAccessor]. It specified

View File

@ -1,11 +1,11 @@
import 'package:meta/meta.dart';
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
/// Subclasses represent a table in a database generated by sally.
/// Subclasses represent a table in a database generated by moor.
abstract class Table {
const Table();
/// The sql table name to be used. By default, sally will use the snake_case
/// The sql table name to be used. By default, moor will use the snake_case
/// representation of your class name as the sql table name. For instance, a
/// [Table] class named `LocalSettings` will be called `local_settings` by
/// default.
@ -30,7 +30,7 @@ abstract class Table {
///}
/// ```
/// The getter must return a set literal using the `=>` syntax so that the
/// sally generator can understand the code.
/// moor generator can understand the code.
/// Also, please not that it's an error to have a
/// [IntColumnBuilder.autoIncrement] column and a custom primary key.
/// Writing such table in sql will throw at runtime.
@ -74,8 +74,8 @@ abstract class Table {
/// A class to to be used as an annotation on [Table] classes to customize the
/// name for the data class that will be generated for the table class. The data
/// class is a dart object that will be used to represent a row in the table.
/// {@template sally:custom_data_class}
/// By default, sally will attempt to use the singular form of the table name
/// {@template moor:custom_data_class}
/// By default, moor will attempt to use the singular form of the table name
/// when naming data classes (e.g. a table named "Users" will generate a data
/// class called "User"). However, this doesn't work for irregular plurals and
/// you might want to choose a different name, for which this annotation can be
@ -85,6 +85,6 @@ class DataClassName {
final String name;
/// Customize the data class name for a given table.
/// {@macro sally:custom_data_class}
/// {@macro moor:custom_data_class}
const DataClassName(this.name);
}

View File

@ -1,4 +1,4 @@
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
/// A component is anything that can appear in a sql query.
abstract class Component {

View File

@ -1,4 +1,4 @@
import 'package:sally/src/runtime/components/component.dart';
import 'package:moor/src/runtime/components/component.dart';
/// A limit clause inside a select, update or delete statement.
class Limit extends Component {

View File

@ -1,6 +1,6 @@
import 'package:meta/meta.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
enum OrderingMode {
/// Ascending ordering mode (lowest items first)

View File

@ -1,6 +1,6 @@
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:moor/src/types/sql_types.dart';
/// A where clause in a select, update or delete statement.
class Where extends Component {

View File

@ -1,11 +1,11 @@
import 'package:meta/meta.dart';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/executor/stream_queries.dart';
import 'package:sally/src/types/type_system.dart';
import 'package:sally/src/runtime/statements/delete.dart';
import 'package:sally/src/runtime/statements/select.dart';
import 'package:sally/src/runtime/statements/update.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/executor/stream_queries.dart';
import 'package:moor/src/types/type_system.dart';
import 'package:moor/src/runtime/statements/delete.dart';
import 'package:moor/src/runtime/statements/select.dart';
import 'package:moor/src/runtime/statements/update.dart';
/// Class that runs queries to a subset of all available queries in a database.
/// This comes in handy to structure large amounts of database code better: The
@ -94,7 +94,7 @@ mixin QueryEngine on DatabaseConnectionUser {
/// Executes a custom delete or update statement and returns the amount of
/// rows that have been changed.
/// You can use the [updates] parameter so that sally knows which tables are
/// You can use the [updates] parameter so that moor knows which tables are
/// affected by your query. All select streams that depend on a table
/// specified there will then issue another query.
Future<int> customUpdate(String query,

View File

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:sally/src/runtime/database.dart';
import 'package:moor/src/runtime/database.dart';
/// A query executor is responsible for executing statements on a database and
/// return their results in a raw form.

View File

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
/// Internal interface to mark classes that respond to table changes
abstract class TableChangeListener<T> {

View File

@ -1,6 +1,6 @@
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:moor/src/types/sql_types.dart';
/// Returns an expression that is true iff both [a] and [b] are true.
Expression<bool, BoolType> and(

View File

@ -1,4 +1,4 @@
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
import 'expression.dart';
abstract class IntExpression extends Expression<int, IntType>

View File

@ -1,6 +1,6 @@
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
class CustomExpression<D, S extends SqlType<D>> extends Expression<D, S> {
final String content;

View File

@ -1,6 +1,6 @@
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
/// Extracts the (UTC) year from the given expression that resolves
/// to a datetime.

View File

@ -1,7 +1,7 @@
import 'package:meta/meta.dart';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/types/sql_types.dart';
/// Any sql expression that evaluates to some generic value. This does not
/// include queries (which might evaluate to multiple values) but individual

View File

@ -1,7 +1,7 @@
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:moor/src/types/sql_types.dart';
/// An expression that is true if the given [expression] resolves to any of the
/// values in [values].

View File

@ -1,6 +1,6 @@
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
/// Expression that is true if the inner expression resolves to a null value.
Expression<bool, BoolType> isNull(Expression inner) => _NullCheck(inner, true);

View File

@ -1,6 +1,6 @@
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:moor/src/types/sql_types.dart';
/// A `text LIKE pattern` expression that will be true if the first expression
/// matches the pattern given by the second expression.

View File

@ -1,6 +1,6 @@
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:moor/src/types/sql_types.dart';
/// An expression that represents the value of a dart object encoded to sql
/// using prepared statements.

View File

@ -1,8 +1,8 @@
import 'dart:async';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/structure/columns.dart';
import 'package:sally/src/runtime/structure/table_info.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/structure/columns.dart';
import 'package:moor/src/runtime/structure/table_info.dart';
typedef Future<void> OnCreate(Migrator m);
typedef Future<void> OnUpgrade(Migrator m, int from, int to);
@ -13,7 +13,7 @@ typedef Future<void> OnMigrationFinished();
Future<void> _defaultOnCreate(Migrator m) => m.createAllTables();
Future<void> _defaultOnUpdate(Migrator m, int from, int to) async =>
throw Exception("You've bumped the schema version for your sally database "
throw Exception("You've bumped the schema version for your moor database "
"but didn't provide a strategy for schema updates. Please do that by "
'adapting the migrations getter in your database class.');

View File

@ -1,9 +1,9 @@
import 'dart:async';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/statements/query.dart';
import 'package:sally/src/runtime/structure/table_info.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/statements/query.dart';
import 'package:moor/src/runtime/structure/table_info.dart';
class DeleteStatement<UserTable> extends Query<UserTable, dynamic> {
/// This constructor should be called by [GeneratedDatabase.delete] for you.

View File

@ -1,8 +1,8 @@
import 'dart:async';
import 'package:meta/meta.dart';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
class InsertStatement<DataClass> {
@protected

View File

@ -1,13 +1,13 @@
import 'package:meta/meta.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/components/limit.dart';
import 'package:sally/src/runtime/components/order_by.dart';
import 'package:sally/src/runtime/components/where.dart';
import 'package:sally/src/runtime/database.dart';
import 'package:sally/src/runtime/expressions/bools.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:sally/src/runtime/structure/table_info.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/components/limit.dart';
import 'package:moor/src/runtime/components/order_by.dart';
import 'package:moor/src/runtime/components/where.dart';
import 'package:moor/src/runtime/database.dart';
import 'package:moor/src/runtime/expressions/bools.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:moor/src/types/sql_types.dart';
import 'package:moor/src/runtime/structure/table_info.dart';
/// Statement that operates with data that already exists (select, delete,
/// update).

View File

@ -1,12 +1,12 @@
import 'dart:async';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/components/limit.dart';
import 'package:sally/src/runtime/database.dart';
import 'package:sally/src/runtime/executor/stream_queries.dart';
import 'package:sally/src/runtime/statements/query.dart';
import 'package:sally/src/runtime/structure/table_info.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/components/limit.dart';
import 'package:moor/src/runtime/database.dart';
import 'package:moor/src/runtime/executor/stream_queries.dart';
import 'package:moor/src/runtime/statements/query.dart';
import 'package:moor/src/runtime/structure/table_info.dart';
typedef OrderingTerm OrderClauseGenerator<T>(T tbl);

View File

@ -1,10 +1,10 @@
import 'dart:async';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/components/where.dart';
import 'package:sally/src/runtime/expressions/custom.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/components/where.dart';
import 'package:moor/src/runtime/expressions/custom.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
class UpdateStatement<T, D> extends Query<T, D> {
UpdateStatement(QueryEngine database, TableInfo<T, D> table)

View File

@ -1,10 +1,10 @@
import 'package:meta/meta.dart';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:sally/src/runtime/expressions/text.dart';
import 'package:sally/src/runtime/expressions/variables.dart';
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:moor/src/runtime/expressions/text.dart';
import 'package:moor/src/runtime/expressions/variables.dart';
import 'package:moor/src/types/sql_types.dart';
/// Base class for the implementation of [Column].
abstract class GeneratedColumn<T, S extends SqlType<T>> extends Column<T, S> {

View File

@ -1,5 +1,5 @@
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/expressions/variables.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/expressions/variables.dart';
/// Base class for generated classes. [TableDsl] is the type specified by the
/// user that extends [Table], [DataClass] is the type of the data class

View File

@ -1,4 +1,4 @@
import 'package:sally/src/types/sql_types.dart';
import 'package:moor/src/types/sql_types.dart';
/// Manages the set of [SqlType] known to a database. It's also responsible for
/// returning the appropriate sql type for a given dart type.

View File

@ -1,7 +1,7 @@
name: sally
description: Sally is a safe and reactive persistence library for Dart applications
name: moor
description: Moor is a safe and reactive persistence library for Dart applications
version: 1.0.0
homepage: https://github.com/simolus3/sally
homepage: https://github.com/simolus3/moor
authors:
- Simon Binder <simolus3@gmail.com>
maintainer: Simon Binder (@simolus3)
@ -13,8 +13,8 @@ dependencies:
meta: '>= 1.0.0 <2.0.0'
dev_dependencies:
sally_generator:
path: ../sally_generator
moor_generator:
path: ../moor_generator
build_runner: ^1.2.0
build_test: ^0.10.6
test: ^1.5.3

View File

@ -1,4 +1,4 @@
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
import 'package:test_api/test_api.dart';
void main() {

View File

@ -1,4 +1,4 @@
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
part 'todos.g.dart';
@ -35,7 +35,7 @@ class SharedTodos extends Table {
Set<Column> get primaryKey => {todo, user};
}
@UseSally(tables: [TodosTable, Categories, Users, SharedTodos])
@Usemoor(tables: [TodosTable, Categories, Users, SharedTodos])
class TodoDb extends _$TodoDb {
TodoDb(QueryExecutor e) : super(e);

View File

@ -3,7 +3,7 @@
part of 'todos.dart';
// **************************************************************************
// SallyGenerator
// moorGenerator
// **************************************************************************
class TodoEntry {

View File

@ -1,8 +1,8 @@
import 'dart:async';
import 'package:mockito/mockito.dart';
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/executor/stream_queries.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/executor/stream_queries.dart';
export 'package:mockito/mockito.dart';

View File

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
import 'package:test_api/test_api.dart';
import 'data/tables/todos.dart';

View File

@ -1,5 +1,5 @@
import 'package:test_api/test_api.dart';
import 'package:sally/diff_util.dart';
import 'package:moor/diff_util.dart';
List<T> applyEditScript<T>(List<T> a, List<T> b, List<EditAction> actions) {
final copy = List.of(a);

View File

@ -1,5 +1,5 @@
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:test_api/test_api.dart';
import '../data/tables/todos.dart';

View File

@ -1,6 +1,6 @@
import 'package:sally/sally.dart';
import 'package:sally/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart';
import 'package:moor/moor.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:test_api/test_api.dart';
typedef Expression<int, IntType> _Extractor(

View File

@ -1,13 +1,13 @@
import 'package:sally/src/runtime/components/component.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:test_api/test_api.dart';
import 'package:sally/sally.dart' as sally;
import 'package:moor/moor.dart' as moor;
import '../data/tables/todos.dart';
void main() {
test('in expressions are generated', () {
final innerExpression = sally.GeneratedTextColumn('name', true);
final isInExpression = sally.isIn(innerExpression, ['Max', 'Tobias']);
final innerExpression = moor.GeneratedTextColumn('name', true);
final isInExpression = moor.isIn(innerExpression, ['Max', 'Tobias']);
final context = GenerationContext(TodoDb(null));
isInExpression.writeInto(context);

View File

@ -1,14 +1,14 @@
import 'package:sally/src/runtime/components/component.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:test_api/test_api.dart';
import 'package:sally/sally.dart' as sally;
import 'package:moor/moor.dart' as moor;
import '../data/tables/todos.dart';
void main() {
final innerExpression = sally.GeneratedTextColumn('name', true);
final innerExpression = moor.GeneratedTextColumn('name', true);
test('IS NULL expressions are generated', () {
final isNull = sally.isNull(innerExpression);
final isNull = moor.isNull(innerExpression);
final context = GenerationContext(TodoDb(null));
isNull.writeInto(context);
@ -17,7 +17,7 @@ void main() {
});
test('IS NOT NULL expressions are generated', () {
final isNotNull = sally.isNotNull(innerExpression);
final isNotNull = moor.isNotNull(innerExpression);
final context = GenerationContext(TodoDb(null));
isNotNull.writeInto(context);

View File

@ -1,6 +1,6 @@
import 'package:sally/src/runtime/components/component.dart';
import 'package:moor/src/runtime/components/component.dart';
import 'package:test_api/test_api.dart';
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
import '../data/tables/todos.dart';

View File

@ -1,4 +1,4 @@
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
import 'package:test_api/test_api.dart';
import 'data/tables/todos.dart';

View File

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
import 'package:test_api/test_api.dart';
import 'data/tables/todos.dart';

View File

@ -1,4 +1,4 @@
import 'package:sally/sally.dart' as sally;
import 'package:moor/moor.dart' as moor;
import 'package:test_api/test_api.dart';
const _exampleUnixSqlite = 1550172560;
@ -7,7 +7,7 @@ final _exampleDateTime =
DateTime.fromMillisecondsSinceEpoch(_exampleUnixMillis);
void main() {
final type = const sally.DateTimeType();
final type = const moor.DateTimeType();
group('DateTimes', () {
test('can be read from unix stamps returned by sql', () {

View File

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:sally/sally.dart';
import 'package:moor/moor.dart';
import 'package:test_api/test_api.dart';
import 'data/tables/todos.dart';

View File

@ -1,12 +1,12 @@
# Sally
[![Build Status](https://travis-ci.com/simolus3/sally.svg?token=u4VnFEE5xnWVvkE6QsqL&branch=master)](https://travis-ci.com/simolus3/sally)
# moor
[![Build Status](https://travis-ci.com/simolus3/moor.svg?token=u4VnFEE5xnWVvkE6QsqL&branch=master)](https://travis-ci.com/simolus3/moor)
Sally is an easy to use and safe way to persist data for Flutter apps. It features
moor is an easy to use and safe way to persist data for Flutter apps. It features
a fluent Dart DSL to describe tables and will generate matching database code that
can be used to easily read and store your app's data. It also features a reactive
API that will deliver auto-updating streams for your queries.
- [Sally](#sally)
- [moor](#moor)
* [Getting started](#getting-started)
+ [Adding the dependency](#adding-the-dependency)
+ [Declaring tables](#declaring-tables)
@ -27,34 +27,34 @@ API that will deliver auto-updating streams for your queries.
## Getting started
### Adding the dependency
First, let's add sally to your project's `pubspec.yaml`. The library is not yet
First, let's add moor to your project's `pubspec.yaml`. The library is not yet
out on pub, so you'll need to use the git repository for now:
```yaml
dependencies:
sally:
moor:
git:
url: https://github.com/simolus3/sally.git
path: sally/
url: https://github.com/simolus3/moor.git
path: moor/
dev_dependencies:
sally_generator:
moor_generator:
git:
url: https://github.com/simolus3/sally.git
path: sally_generator/
url: https://github.com/simolus3/moor.git
path: moor_generator/
build_runner: ^1.2.0
```
We're going to use the `sally_flutter` library to specify tables and access the database. The
`sally_generator` library will take care of generating the necessary code so the
We're going to use the `moor_flutter` library to specify tables and access the database. The
`moor_generator` library will take care of generating the necessary code so the
library knows how your table structure looks like.
### Declaring tables
You can use the DSL included with this library to specify your libraries with simple
dart code:
```dart
import 'package:sally_flutter/sally_flutter.dart';
import 'package:moor_flutter/moor_flutter.dart';
// assuming that your file is called filename.dart. This will give an error at first,
// but it's needed for sally to know about the generated code
// but it's needed for moor to know about the generated code
part 'filename.g.dart';
// this will generate a table called "todos" for us. The rows of that table will
@ -66,7 +66,7 @@ class Todos extends Table {
IntColumn get category => integer().nullable()();
}
// This will make sally generate a class called "Category" to represent a row in this table.
// This will make moor generate a class called "Category" to represent a row in this table.
// By default, "Categorie" would have been used because it only strips away the trailing "s"
// in the table name.
@DataClassName("Category")
@ -76,9 +76,9 @@ class Categories extends Table {
TextColumn get description => text()();
}
// this annotation tells sally to prepare a database class that uses both of the
// this annotation tells moor to prepare a database class that uses both of the
// tables we just defined. We'll see how to use that database class in a moment.
@UseSally(tables: [Todos, Categories])
@Usemoor(tables: [Todos, Categories])
class MyDatabase {
}
@ -90,14 +90,14 @@ executed. Instead, the generator will take a look at your table classes to figur
This won't work if the body of your tables is not constant. This should not be problem, but please be aware of this as you can't put logic inside these classes.
### Generating the code
Sally integrates with the dart `build` system, so you can generate all the code needed with
moor integrates with the dart `build` system, so you can generate all the code needed with
`flutter packages pub run build_runner build`. If you want to continously rebuild the code
whever you change your code, run `flutter packages pub run build_runner watch` instead.
After running either command once, sally generator will have created a class for your
After running either command once, moor generator will have created a class for your
database and data classes for your entities. To use it, change the `MyDatabase` class as
follows:
```dart
@UseSally(tables: [Todos, Categories])
@Usemoor(tables: [Todos, Categories])
class MyDatabase extends _$MyDatabase {
// we tell the database where to store the data with this constructor
MyDatabase() : super(FlutterQueryExecutor.inDatabaseFolder(path: 'db.sqlite'));
@ -128,7 +128,7 @@ class MyDatabase extends _$MyDatabase {
### Select statements
You can create `select` statements by starting them with `select(tableName)`, where the
table name
is a field generated for you by sally. Each table used in a database will have a matching field
is a field generated for you by moor. Each table used in a database will have a matching field
to run queries against. A query can be run once with `get()` or be turned into an auto-updating
stream using `watch()`.
#### Where
@ -232,7 +232,7 @@ Stream<List<CategoryWithCount>> categoriesWithCount() {
```
## Migrations
Sally provides a migration API that can be used to gradually apply schema changes after bumping
moor provides a migration API that can be used to gradually apply schema changes after bumping
the `schemaVersion` getter inside the `Database` class. To use it, override the `migration`
getter. Here's an example: Let's say you wanted to add a due date to your todo entries:
```dart
@ -273,7 +273,7 @@ available from your main database class. Consider the following code:
```dart
part 'todos_dao.g.dart';
// the _TodosDaoMixin will be created by sally. It contains all the necessary
// the _TodosDaoMixin will be created by moor. It contains all the necessary
// fields for the tables. The <MyDatabase> type annotation is the database class
// that should use this dao.
@UseDao(tables: [Todos])
@ -292,7 +292,7 @@ class TodosDao extends DatabaseAccessor<MyDatabase> with _TodosDaoMixin {
}
}
```
If we now change the annotation on the `MyDatabase` class to `@UseSally(tables: [Todos, Categories], daos: [TodosDao])`
If we now change the annotation on the `MyDatabase` class to `@Usemoor(tables: [Todos, Categories], daos: [TodosDao])`
and re-run the code generation, a getter `todosDao` can be used to access the instance of that dao.
## TODO-List and current limitations

View File

@ -38,7 +38,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "eu.simonbinder.sallyexample.sallyexample"
applicationId "eu.simonbinder.moorexample.moorexample"
minSdkVersion 16
targetSdkVersion 27
versionCode flutterVersionCode.toInteger()

View File

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="eu.simonbinder.sallyexample.sallyexample">
package="eu.simonbinder.moorexample.moorexample">
<!-- The INTERNET permission is required for development. Specifically,
flutter needs it to communicate with the running application
@ -14,7 +14,7 @@
FlutterApplication and put your custom class here. -->
<application
android:name="io.flutter.app.FlutterApplication"
android:label="sally_example"
android:label="moor_example"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"

View File

@ -1,4 +1,4 @@
package eu.simonbinder.sallyexample.sallyexample
package eu.simonbinder.moorexample.moorexample
import android.os.Bundle

View File

@ -323,7 +323,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = eu.simonbinder.sally_example.sallyExample;
PRODUCT_BUNDLE_IDENTIFIER = eu.simonbinder.moor_example.moorExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
VERSIONING_SYSTEM = "apple-generic";
@ -451,7 +451,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = eu.simonbinder.sally_example.sallyExample;
PRODUCT_BUNDLE_IDENTIFIER = eu.simonbinder.moor_example.moorExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@ -479,7 +479,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = eu.simonbinder.sally_example.sallyExample;
PRODUCT_BUNDLE_IDENTIFIER = eu.simonbinder.moor_example.moorExample;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
SWIFT_SWIFT3_OBJC_INFERENCE = On;

Some files were not shown because too many files have changed in this diff Show More