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'; part 'example.g.dart';
@ -37,7 +37,7 @@ class IngredientInRecipes extends Table {
IntColumn get amountInGrams => integer().named('amount')(); IntColumn get amountInGrams => integer().named('amount')();
} }
@UseSally(tables: [Categories, Recipes, Ingredients, IngredientInRecipes]) @Usemoor(tables: [Categories, Recipes, Ingredients, IngredientInRecipes])
class Database extends _$Database { class Database extends _$Database {
Database(QueryExecutor e) : super(e); Database(QueryExecutor e) : super(e);

View File

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

View File

@ -3,7 +3,7 @@
/// list that can be updated. /// list that can be updated.
library diff_util; 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 { class EditAction {
/// The index of the first list on which this action should be applied. If /// 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) // todo more datatypes (at least binary blobs)
import 'package:sally/src/runtime/expressions/expression.dart'; import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:sally/src/runtime/expressions/comparable.dart'; import 'package:moor/src/runtime/expressions/comparable.dart';
import 'package:sally/src/types/sql_types.dart'; import 'package:moor/src/types/sql_types.dart';
abstract class Column<T, S extends SqlType<T>> extends Expression<T, S> {} 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. /// 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 /// 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 /// source code (specifically, it will analyze which of the methods you use) to
/// figure out the column structure of a table. /// figure out the column structure of a table.
class ColumnBuilder<Builder, ResultColumn> { class ColumnBuilder<Builder, ResultColumn> {
@ -45,7 +45,7 @@ class ColumnBuilder<Builder, ResultColumn> {
Builder nullable() => null; Builder nullable() => null;
/// Turns this column builder into a column. This method won't actually be /// 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. /// source code to figure out your table structure.
ResultColumn call() => null; ResultColumn call() => null;
} }

View File

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

View File

@ -1,11 +1,11 @@
import 'package:meta/meta.dart'; 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 { abstract class Table {
const 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 /// representation of your class name as the sql table name. For instance, a
/// [Table] class named `LocalSettings` will be called `local_settings` by /// [Table] class named `LocalSettings` will be called `local_settings` by
/// default. /// default.
@ -30,7 +30,7 @@ abstract class Table {
///} ///}
/// ``` /// ```
/// The getter must return a set literal using the `=>` syntax so that the /// 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 /// Also, please not that it's an error to have a
/// [IntColumnBuilder.autoIncrement] column and a custom primary key. /// [IntColumnBuilder.autoIncrement] column and a custom primary key.
/// Writing such table in sql will throw at runtime. /// 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 /// 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 /// 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. /// class is a dart object that will be used to represent a row in the table.
/// {@template sally:custom_data_class} /// {@template moor:custom_data_class}
/// By default, sally will attempt to use the singular form of the table name /// 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 /// 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 /// 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 /// you might want to choose a different name, for which this annotation can be
@ -85,6 +85,6 @@ class DataClassName {
final String name; final String name;
/// Customize the data class name for a given table. /// Customize the data class name for a given table.
/// {@macro sally:custom_data_class} /// {@macro moor:custom_data_class}
const DataClassName(this.name); 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. /// A component is anything that can appear in a sql query.
abstract class Component { 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. /// A limit clause inside a select, update or delete statement.
class Limit extends Component { class Limit extends Component {

View File

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

View File

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

View File

@ -1,11 +1,11 @@
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:sally/sally.dart'; import 'package:moor/moor.dart';
import 'package:sally/src/runtime/components/component.dart'; import 'package:moor/src/runtime/components/component.dart';
import 'package:sally/src/runtime/executor/stream_queries.dart'; import 'package:moor/src/runtime/executor/stream_queries.dart';
import 'package:sally/src/types/type_system.dart'; import 'package:moor/src/types/type_system.dart';
import 'package:sally/src/runtime/statements/delete.dart'; import 'package:moor/src/runtime/statements/delete.dart';
import 'package:sally/src/runtime/statements/select.dart'; import 'package:moor/src/runtime/statements/select.dart';
import 'package:sally/src/runtime/statements/update.dart'; import 'package:moor/src/runtime/statements/update.dart';
/// Class that runs queries to a subset of all available queries in a database. /// 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 /// 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 /// Executes a custom delete or update statement and returns the amount of
/// rows that have been changed. /// 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 /// affected by your query. All select streams that depend on a table
/// specified there will then issue another query. /// specified there will then issue another query.
Future<int> customUpdate(String query, Future<int> customUpdate(String query,

View File

@ -1,6 +1,6 @@
import 'dart:async'; 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 /// A query executor is responsible for executing statements on a database and
/// return their results in a raw form. /// return their results in a raw form.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
import 'package:sally/sally.dart'; import 'package:moor/moor.dart';
import 'package:sally/src/runtime/components/component.dart'; import 'package:moor/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart'; import 'package:moor/src/runtime/expressions/expression.dart';
/// Expression that is true if the inner expression resolves to a null value. /// Expression that is true if the inner expression resolves to a null value.
Expression<bool, BoolType> isNull(Expression inner) => _NullCheck(inner, true); 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:moor/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart'; import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:sally/src/types/sql_types.dart'; import 'package:moor/src/types/sql_types.dart';
/// A `text LIKE pattern` expression that will be true if the first expression /// A `text LIKE pattern` expression that will be true if the first expression
/// matches the pattern given by the second 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:moor/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart'; import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:sally/src/types/sql_types.dart'; import 'package:moor/src/types/sql_types.dart';
/// An expression that represents the value of a dart object encoded to sql /// An expression that represents the value of a dart object encoded to sql
/// using prepared statements. /// using prepared statements.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:sally/sally.dart'; import 'package:moor/moor.dart';
import 'package:sally/src/runtime/components/component.dart'; import 'package:moor/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart'; import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:sally/src/runtime/expressions/text.dart'; import 'package:moor/src/runtime/expressions/text.dart';
import 'package:sally/src/runtime/expressions/variables.dart'; import 'package:moor/src/runtime/expressions/variables.dart';
import 'package:sally/src/types/sql_types.dart'; import 'package:moor/src/types/sql_types.dart';
/// Base class for the implementation of [Column]. /// Base class for the implementation of [Column].
abstract class GeneratedColumn<T, S extends SqlType<T>> extends Column<T, S> { 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:moor/moor.dart';
import 'package:sally/src/runtime/expressions/variables.dart'; import 'package:moor/src/runtime/expressions/variables.dart';
/// Base class for generated classes. [TableDsl] is the type specified by the /// Base class for generated classes. [TableDsl] is the type specified by the
/// user that extends [Table], [DataClass] is the type of the data class /// 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 /// Manages the set of [SqlType] known to a database. It's also responsible for
/// returning the appropriate sql type for a given dart type. /// returning the appropriate sql type for a given dart type.

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
import 'package:test_api/test_api.dart'; 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) { List<T> applyEditScript<T>(List<T> a, List<T> b, List<EditAction> actions) {
final copy = List.of(a); final copy = List.of(a);

View File

@ -1,5 +1,5 @@
import 'package:sally/sally.dart'; import 'package:moor/moor.dart';
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:test_api/test_api.dart';
import '../data/tables/todos.dart'; import '../data/tables/todos.dart';

View File

@ -1,6 +1,6 @@
import 'package:sally/sally.dart'; import 'package:moor/moor.dart';
import 'package:sally/src/runtime/components/component.dart'; import 'package:moor/src/runtime/components/component.dart';
import 'package:sally/src/runtime/expressions/expression.dart'; import 'package:moor/src/runtime/expressions/expression.dart';
import 'package:test_api/test_api.dart'; import 'package:test_api/test_api.dart';
typedef Expression<int, IntType> _Extractor( 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:test_api/test_api.dart';
import 'package:sally/sally.dart' as sally; import 'package:moor/moor.dart' as moor;
import '../data/tables/todos.dart'; import '../data/tables/todos.dart';
void main() { void main() {
test('in expressions are generated', () { test('in expressions are generated', () {
final innerExpression = sally.GeneratedTextColumn('name', true); final innerExpression = moor.GeneratedTextColumn('name', true);
final isInExpression = sally.isIn(innerExpression, ['Max', 'Tobias']); final isInExpression = moor.isIn(innerExpression, ['Max', 'Tobias']);
final context = GenerationContext(TodoDb(null)); final context = GenerationContext(TodoDb(null));
isInExpression.writeInto(context); 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:test_api/test_api.dart';
import 'package:sally/sally.dart' as sally; import 'package:moor/moor.dart' as moor;
import '../data/tables/todos.dart'; import '../data/tables/todos.dart';
void main() { void main() {
final innerExpression = sally.GeneratedTextColumn('name', true); final innerExpression = moor.GeneratedTextColumn('name', true);
test('IS NULL expressions are generated', () { test('IS NULL expressions are generated', () {
final isNull = sally.isNull(innerExpression); final isNull = moor.isNull(innerExpression);
final context = GenerationContext(TodoDb(null)); final context = GenerationContext(TodoDb(null));
isNull.writeInto(context); isNull.writeInto(context);
@ -17,7 +17,7 @@ void main() {
}); });
test('IS NOT NULL expressions are generated', () { test('IS NOT NULL expressions are generated', () {
final isNotNull = sally.isNotNull(innerExpression); final isNotNull = moor.isNotNull(innerExpression);
final context = GenerationContext(TodoDb(null)); final context = GenerationContext(TodoDb(null));
isNotNull.writeInto(context); 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:test_api/test_api.dart';
import 'package:sally/sally.dart'; import 'package:moor/moor.dart';
import '../data/tables/todos.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 'package:test_api/test_api.dart';
import 'data/tables/todos.dart'; import 'data/tables/todos.dart';

View File

@ -1,6 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'package:sally/sally.dart'; import 'package:moor/moor.dart';
import 'package:test_api/test_api.dart'; import 'package:test_api/test_api.dart';
import 'data/tables/todos.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'; import 'package:test_api/test_api.dart';
const _exampleUnixSqlite = 1550172560; const _exampleUnixSqlite = 1550172560;
@ -7,7 +7,7 @@ final _exampleDateTime =
DateTime.fromMillisecondsSinceEpoch(_exampleUnixMillis); DateTime.fromMillisecondsSinceEpoch(_exampleUnixMillis);
void main() { void main() {
final type = const sally.DateTimeType(); final type = const moor.DateTimeType();
group('DateTimes', () { group('DateTimes', () {
test('can be read from unix stamps returned by sql', () { test('can be read from unix stamps returned by sql', () {

View File

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

View File

@ -1,12 +1,12 @@
# Sally # moor
[![Build Status](https://travis-ci.com/simolus3/sally.svg?token=u4VnFEE5xnWVvkE6QsqL&branch=master)](https://travis-ci.com/simolus3/sally) [![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 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 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. API that will deliver auto-updating streams for your queries.
- [Sally](#sally) - [moor](#moor)
* [Getting started](#getting-started) * [Getting started](#getting-started)
+ [Adding the dependency](#adding-the-dependency) + [Adding the dependency](#adding-the-dependency)
+ [Declaring tables](#declaring-tables) + [Declaring tables](#declaring-tables)
@ -27,34 +27,34 @@ API that will deliver auto-updating streams for your queries.
## Getting started ## Getting started
### Adding the dependency ### 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: out on pub, so you'll need to use the git repository for now:
```yaml ```yaml
dependencies: dependencies:
sally: moor:
git: git:
url: https://github.com/simolus3/sally.git url: https://github.com/simolus3/moor.git
path: sally/ path: moor/
dev_dependencies: dev_dependencies:
sally_generator: moor_generator:
git: git:
url: https://github.com/simolus3/sally.git url: https://github.com/simolus3/moor.git
path: sally_generator/ path: moor_generator/
build_runner: ^1.2.0 build_runner: ^1.2.0
``` ```
We're going to use the `sally_flutter` library to specify tables and access the database. The We're going to use the `moor_flutter` library to specify tables and access the database. The
`sally_generator` library will take care of generating the necessary code so the `moor_generator` library will take care of generating the necessary code so the
library knows how your table structure looks like. library knows how your table structure looks like.
### Declaring tables ### Declaring tables
You can use the DSL included with this library to specify your libraries with simple You can use the DSL included with this library to specify your libraries with simple
dart code: dart code:
```dart ```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, // 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'; part 'filename.g.dart';
// this will generate a table called "todos" for us. The rows of that table will // 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()(); 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" // By default, "Categorie" would have been used because it only strips away the trailing "s"
// in the table name. // in the table name.
@DataClassName("Category") @DataClassName("Category")
@ -76,9 +76,9 @@ class Categories extends Table {
TextColumn get description => text()(); 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. // 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 { 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. 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 ### 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 `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. 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 database and data classes for your entities. To use it, change the `MyDatabase` class as
follows: follows:
```dart ```dart
@UseSally(tables: [Todos, Categories]) @Usemoor(tables: [Todos, Categories])
class MyDatabase extends _$MyDatabase { class MyDatabase extends _$MyDatabase {
// we tell the database where to store the data with this constructor // we tell the database where to store the data with this constructor
MyDatabase() : super(FlutterQueryExecutor.inDatabaseFolder(path: 'db.sqlite')); MyDatabase() : super(FlutterQueryExecutor.inDatabaseFolder(path: 'db.sqlite'));
@ -128,7 +128,7 @@ class MyDatabase extends _$MyDatabase {
### Select statements ### Select statements
You can create `select` statements by starting them with `select(tableName)`, where the You can create `select` statements by starting them with `select(tableName)`, where the
table name 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 to run queries against. A query can be run once with `get()` or be turned into an auto-updating
stream using `watch()`. stream using `watch()`.
#### Where #### Where
@ -232,7 +232,7 @@ Stream<List<CategoryWithCount>> categoriesWithCount() {
``` ```
## Migrations ## 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` 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: getter. Here's an example: Let's say you wanted to add a due date to your todo entries:
```dart ```dart
@ -273,7 +273,7 @@ available from your main database class. Consider the following code:
```dart ```dart
part 'todos_dao.g.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 // fields for the tables. The <MyDatabase> type annotation is the database class
// that should use this dao. // that should use this dao.
@UseDao(tables: [Todos]) @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. and re-run the code generation, a getter `todosDao` can be used to access the instance of that dao.
## TODO-List and current limitations ## TODO-List and current limitations

View File

@ -38,7 +38,7 @@ android {
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // 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 minSdkVersion 16
targetSdkVersion 27 targetSdkVersion 27
versionCode flutterVersionCode.toInteger() versionCode flutterVersionCode.toInteger()

View File

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

View File

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

View File

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

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