mirror of https://github.com/AMT-Cheif/drift.git
Finalize renaming
This commit is contained in:
parent
62900a93a9
commit
4d80ff77c9
|
@ -4,8 +4,8 @@ dart:
|
||||||
- stable
|
- stable
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- PKG="sally"
|
- PKG="moor"
|
||||||
- PKG="sally_generator"
|
- PKG="moor_generator"
|
||||||
|
|
||||||
script: ./tool/mono_repo_wrapper.sh
|
script: ./tool/mono_repo_wrapper.sh
|
||||||
|
|
||||||
|
@ -17,5 +17,5 @@ branches:
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- "$HOME/.pub-cache"
|
- "$HOME/.pub-cache"
|
||||||
- sally/.dart_tool/build
|
- moor/.dart_tool/build
|
||||||
- sally_generator/.dart_tool/build
|
- moor_generator/.dart_tool/build
|
||||||
|
|
50
README.md
50
README.md
|
@ -1,12 +1,12 @@
|
||||||
# Sally
|
# Moor
|
||||||
[](https://travis-ci.com/simolus3/sally)
|
[](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
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
part of 'example.dart';
|
part of 'example.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// moorGenerator
|
// MoorGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
class Category {
|
class Category {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
part of 'todos.dart';
|
part of 'todos.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// moorGenerator
|
// MoorGenerator
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
|
|
||||||
class TodoEntry {
|
class TodoEntry {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# moor
|
# Moor
|
||||||
[](https://travis-ci.com/simolus3/moor)
|
[](https://travis-ci.com/simolus3/moor)
|
||||||
|
|
||||||
moor 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.
|
||||||
|
|
|
@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
|
||||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 27
|
compileSdkVersion 28
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
@ -38,9 +38,9 @@ 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.moorexample.moorexample"
|
applicationId "eu.simonbinder.moor_example.example"
|
||||||
minSdkVersion 16
|
minSdkVersion 16
|
||||||
targetSdkVersion 27
|
targetSdkVersion 28
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="eu.simonbinder.moor_example.example">
|
||||||
|
<!-- Flutter needs it to communicate with the running application
|
||||||
|
to allow setting breakpoints, to provide hot reload, etc.
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
|
@ -1,11 +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.moorexample.moorexample">
|
package="eu.simonbinder.moor_example.example">
|
||||||
|
|
||||||
<!-- The INTERNET permission is required for development. Specifically,
|
|
||||||
flutter needs it to communicate with the running application
|
|
||||||
to allow setting breakpoints, to provide hot reload, etc.
|
|
||||||
-->
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
|
||||||
|
|
||||||
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
|
||||||
calls FlutterMain.startInitialization(this); in its onCreate method.
|
calls FlutterMain.startInitialization(this); in its onCreate method.
|
||||||
|
@ -14,13 +8,13 @@
|
||||||
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="moor_example"
|
android:label="example"
|
||||||
android:icon="@mipmap/ic_launcher">
|
android:icon="@mipmap/ic_launcher">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:launchMode="singleTop"
|
android:launchMode="singleTop"
|
||||||
android:theme="@style/LaunchTheme"
|
android:theme="@style/LaunchTheme"
|
||||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
|
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
|
||||||
android:hardwareAccelerated="true"
|
android:hardwareAccelerated="true"
|
||||||
android:windowSoftInputMode="adjustResize">
|
android:windowSoftInputMode="adjustResize">
|
||||||
<!-- This keeps the window background of the activity showing
|
<!-- This keeps the window background of the activity showing
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.simonbinder.moorexample.moorexample
|
package eu.simonbinder.moor_example.example
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="eu.simonbinder.moor_example.example">
|
||||||
|
<!-- Flutter needs it to communicate with the running application
|
||||||
|
to allow setting breakpoints, to provide hot reload, etc.
|
||||||
|
-->
|
||||||
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
|
</manifest>
|
|
@ -4,4 +4,4 @@ import 'package:source_gen/source_gen.dart';
|
||||||
import 'package:moor_generator/src/moor_generator.dart';
|
import 'package:moor_generator/src/moor_generator.dart';
|
||||||
|
|
||||||
Builder moorBuilder(BuilderOptions _) =>
|
Builder moorBuilder(BuilderOptions _) =>
|
||||||
SharedPartBuilder([moorGenerator(), DaoGenerator()], 'moor');
|
SharedPartBuilder([MoorGenerator(), DaoGenerator()], 'moor');
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import 'package:analyzer/dart/element/element.dart';
|
import 'package:analyzer/dart/element/element.dart';
|
||||||
|
|
||||||
class moorError {
|
class MoorError {
|
||||||
final bool critical;
|
final bool critical;
|
||||||
final String message;
|
final String message;
|
||||||
final Element affectedElement;
|
final Element affectedElement;
|
||||||
|
|
||||||
moorError({this.critical = false, this.message, this.affectedElement});
|
MoorError({this.critical = false, this.message, this.affectedElement});
|
||||||
}
|
}
|
||||||
|
|
||||||
class ErrorStore {
|
class ErrorStore {
|
||||||
final List<moorError> errors = [];
|
final List<MoorError> errors = [];
|
||||||
|
|
||||||
void add(moorError error) => errors.add(error);
|
void add(MoorError error) => errors.add(error);
|
||||||
|
|
||||||
bool get hasCriticalError => errors.any((e) => e.critical);
|
bool get hasCriticalError => errors.any((e) => e.critical);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import 'package:moor_generator/src/parser/table_parser.dart';
|
||||||
import 'package:moor_generator/src/writer/database_writer.dart';
|
import 'package:moor_generator/src/writer/database_writer.dart';
|
||||||
import 'package:source_gen/source_gen.dart';
|
import 'package:source_gen/source_gen.dart';
|
||||||
|
|
||||||
class moorGenerator extends GeneratorForAnnotation<Usemoor> {
|
class MoorGenerator extends GeneratorForAnnotation<Usemoor> {
|
||||||
//final Map<String, ParsedLibraryResult> _astForLibs = {};
|
//final Map<String, ParsedLibraryResult> _astForLibs = {};
|
||||||
final ErrorStore errors = ErrorStore();
|
final ErrorStore errors = ErrorStore();
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ class moorGenerator extends GeneratorForAnnotation<Usemoor> {
|
||||||
|
|
||||||
for (var table in tableTypes) {
|
for (var table in tableTypes) {
|
||||||
if (!tableTypeChecker.isAssignableFrom(table.element)) {
|
if (!tableTypeChecker.isAssignableFrom(table.element)) {
|
||||||
errors.add(moorError(
|
errors.add(MoorError(
|
||||||
critical: true,
|
critical: true,
|
||||||
message: 'The type $table is not a moor table',
|
message: 'The type $table is not a moor table',
|
||||||
affectedElement: element));
|
affectedElement: element));
|
|
@ -24,7 +24,7 @@ const String errorMessage = 'This getter does not create a valid column that '
|
||||||
'columns are formed. If you have any questions, feel free to raise an issue.';
|
'columns are formed. If you have any questions, feel free to raise an issue.';
|
||||||
|
|
||||||
class ColumnParser extends ParserBase {
|
class ColumnParser extends ParserBase {
|
||||||
ColumnParser(moorGenerator generator) : super(generator);
|
ColumnParser(MoorGenerator generator) : super(generator);
|
||||||
|
|
||||||
SpecifiedColumn parse(MethodDeclaration getter) {
|
SpecifiedColumn parse(MethodDeclaration getter) {
|
||||||
/*
|
/*
|
||||||
|
@ -39,7 +39,7 @@ class ColumnParser extends ParserBase {
|
||||||
final expr = returnExpressionOfMethod(getter);
|
final expr = returnExpressionOfMethod(getter);
|
||||||
|
|
||||||
if (!(expr is FunctionExpressionInvocation)) {
|
if (!(expr is FunctionExpressionInvocation)) {
|
||||||
generator.errors.add(moorError(
|
generator.errors.add(MoorError(
|
||||||
affectedElement: getter.declaredElement,
|
affectedElement: getter.declaredElement,
|
||||||
message: errorMessage,
|
message: errorMessage,
|
||||||
critical: true,
|
critical: true,
|
||||||
|
@ -69,7 +69,7 @@ class ColumnParser extends ParserBase {
|
||||||
switch (methodName) {
|
switch (methodName) {
|
||||||
case functionNamed:
|
case functionNamed:
|
||||||
if (foundExplicitName != null) {
|
if (foundExplicitName != null) {
|
||||||
generator.errors.add(moorError(
|
generator.errors.add(MoorError(
|
||||||
critical: false,
|
critical: false,
|
||||||
affectedElement: getter.declaredElement,
|
affectedElement: getter.declaredElement,
|
||||||
message:
|
message:
|
||||||
|
@ -79,7 +79,7 @@ class ColumnParser extends ParserBase {
|
||||||
|
|
||||||
foundExplicitName =
|
foundExplicitName =
|
||||||
readStringLiteral(remainingExpr.argumentList.arguments.first, () {
|
readStringLiteral(remainingExpr.argumentList.arguments.first, () {
|
||||||
generator.errors.add(moorError(
|
generator.errors.add(MoorError(
|
||||||
critical: false,
|
critical: false,
|
||||||
affectedElement: getter.declaredElement,
|
affectedElement: getter.declaredElement,
|
||||||
message:
|
message:
|
||||||
|
|
|
@ -10,7 +10,7 @@ class Parser {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ParserBase {
|
class ParserBase {
|
||||||
final moorGenerator generator;
|
final MoorGenerator generator;
|
||||||
|
|
||||||
ParserBase(this.generator);
|
ParserBase(this.generator);
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ class ParserBase {
|
||||||
final body = method.body;
|
final body = method.body;
|
||||||
|
|
||||||
if (!(body is ExpressionFunctionBody)) {
|
if (!(body is ExpressionFunctionBody)) {
|
||||||
generator.errors.add(moorError(
|
generator.errors.add(MoorError(
|
||||||
affectedElement: method.declaredElement,
|
affectedElement: method.declaredElement,
|
||||||
critical: true,
|
critical: true,
|
||||||
message:
|
message:
|
||||||
|
|
|
@ -11,7 +11,7 @@ import 'package:moor_generator/src/moor_generator.dart'; // ignore: implementati
|
||||||
import 'package:recase/recase.dart';
|
import 'package:recase/recase.dart';
|
||||||
|
|
||||||
class TableParser extends ParserBase {
|
class TableParser extends ParserBase {
|
||||||
TableParser(moorGenerator generator) : super(generator);
|
TableParser(MoorGenerator generator) : super(generator);
|
||||||
|
|
||||||
SpecifiedTable parse(ClassElement element) {
|
SpecifiedTable parse(ClassElement element) {
|
||||||
final sqlName = _parseTableName(element);
|
final sqlName = _parseTableName(element);
|
||||||
|
@ -58,7 +58,7 @@ class TableParser extends ParserBase {
|
||||||
tableNameDeclaration.node as MethodDeclaration);
|
tableNameDeclaration.node as MethodDeclaration);
|
||||||
|
|
||||||
final tableName = readStringLiteral(returnExpr, () {
|
final tableName = readStringLiteral(returnExpr, () {
|
||||||
generator.errors.add(moorError(
|
generator.errors.add(MoorError(
|
||||||
critical: true,
|
critical: true,
|
||||||
message:
|
message:
|
||||||
'This getter must return a string literal, and do nothing more',
|
'This getter must return a string literal, and do nothing more',
|
||||||
|
@ -79,7 +79,7 @@ class TableParser extends ParserBase {
|
||||||
as MethodDeclaration;
|
as MethodDeclaration;
|
||||||
final body = ast.body;
|
final body = ast.body;
|
||||||
if (body is! ExpressionFunctionBody) {
|
if (body is! ExpressionFunctionBody) {
|
||||||
generator.errors.add(moorError(
|
generator.errors.add(MoorError(
|
||||||
affectedElement: primaryKeyGetter,
|
affectedElement: primaryKeyGetter,
|
||||||
message: 'This must return a set literal using the => syntax!'));
|
message: 'This must return a set literal using the => syntax!'));
|
||||||
return null;
|
return null;
|
||||||
|
@ -105,7 +105,7 @@ class TableParser extends ParserBase {
|
||||||
parsedPrimaryKey.add(column);
|
parsedPrimaryKey.add(column);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
generator.errors.add(moorError(
|
generator.errors.add(MoorError(
|
||||||
affectedElement: primaryKeyGetter,
|
affectedElement: primaryKeyGetter,
|
||||||
message: 'This must return a set literal!'));
|
message: 'This must return a set literal!'));
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -8,7 +8,7 @@ import 'package:build_test/build_test.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
LibraryElement testLib;
|
LibraryElement testLib;
|
||||||
moorGenerator generator;
|
MoorGenerator generator;
|
||||||
|
|
||||||
setUpAll(() async {
|
setUpAll(() async {
|
||||||
testLib = await resolveSource(r'''
|
testLib = await resolveSource(r'''
|
||||||
|
@ -48,7 +48,7 @@ void main() async {
|
||||||
});
|
});
|
||||||
|
|
||||||
setUp(() {
|
setUp(() {
|
||||||
generator = moorGenerator();
|
generator = MoorGenerator();
|
||||||
generator
|
generator
|
||||||
..columnParser = ColumnParser(generator)
|
..columnParser = ColumnParser(generator)
|
||||||
..tableParser = TableParser(generator);
|
..tableParser = TableParser(generator);
|
||||||
|
|
Loading…
Reference in New Issue