Apply pedantic lints
This commit is contained in:
parent
3eab7be268
commit
532b6be4b2
12 changed files with 38 additions and 36 deletions
|
@ -5,4 +5,4 @@ class JoinOn {
|
|||
final SqlExpressionBuilder value;
|
||||
|
||||
JoinOn(this.key, this.value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ abstract class QueryExecutor {
|
|||
///
|
||||
/// If [f] fails, the transaction will be rolled back, and the
|
||||
/// responsible exception will be re-thrown.
|
||||
///
|
||||
///
|
||||
/// Whether nested transactions are supported depends on the
|
||||
/// underlying driver.
|
||||
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f);
|
||||
|
|
|
@ -56,4 +56,4 @@ abstract class QueryValues {
|
|||
}
|
||||
return b.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ class TodoQueryValues extends MapQueryValues {
|
|||
class Todo extends _Todo {
|
||||
Todo(
|
||||
{this.id,
|
||||
@required this.isComplete = false,
|
||||
this.isComplete = false,
|
||||
this.text,
|
||||
this.createdAt,
|
||||
this.updatedAt});
|
||||
|
|
|
@ -2,7 +2,7 @@ import 'dart:async';
|
|||
import 'package:angel_orm/angel_orm.dart';
|
||||
import 'package:angel_orm/src/query.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:pool/pool.dart';
|
||||
// import 'package:pool/pool.dart';
|
||||
import 'package:sqljocky5/connection/connection.dart';
|
||||
import 'package:sqljocky5/sqljocky.dart';
|
||||
|
||||
|
|
|
@ -17,4 +17,7 @@ dev_dependencies:
|
|||
angel_orm_test:
|
||||
path: ../angel_orm_test
|
||||
build_runner: ^1.0.0
|
||||
test: ^1.0.0
|
||||
test: ^1.0.0
|
||||
dependency_overrides:
|
||||
angel_migration:
|
||||
path: ../angel_migration
|
|
@ -179,7 +179,7 @@ class Todo extends _Todo {
|
|||
String text,
|
||||
DateTime createdAt,
|
||||
DateTime updatedAt}) {
|
||||
return new Todo(
|
||||
return Todo(
|
||||
id: id ?? this.id,
|
||||
isComplete: isComplete ?? this.isComplete,
|
||||
text: text ?? this.text,
|
||||
|
@ -215,7 +215,7 @@ class Todo extends _Todo {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
const TodoSerializer todoSerializer = const TodoSerializer();
|
||||
const TodoSerializer todoSerializer = TodoSerializer();
|
||||
|
||||
class TodoEncoder extends Converter<Todo, Map> {
|
||||
const TodoEncoder();
|
||||
|
@ -240,10 +240,10 @@ class TodoSerializer extends Codec<Todo, Map> {
|
|||
get decoder => const TodoDecoder();
|
||||
static Todo fromMap(Map map) {
|
||||
if (map['text'] == null) {
|
||||
throw new FormatException("Missing required field 'text' on Todo.");
|
||||
throw FormatException("Missing required field 'text' on Todo.");
|
||||
}
|
||||
|
||||
return new Todo(
|
||||
return Todo(
|
||||
id: map['id'] as String,
|
||||
isComplete: map['is_complete'] as bool ?? false,
|
||||
text: map['text'] as String,
|
||||
|
@ -264,7 +264,7 @@ class TodoSerializer extends Codec<Todo, Map> {
|
|||
return null;
|
||||
}
|
||||
if (model.text == null) {
|
||||
throw new FormatException("Missing required field 'text' on Todo.");
|
||||
throw FormatException("Missing required field 'text' on Todo.");
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -67,9 +67,9 @@ class OrmService<Id, Data, TQuery extends Query<Data, QueryWhere>>
|
|||
if (v is Map) {
|
||||
v.forEach((key, value) {
|
||||
var descending = false;
|
||||
if (value is String)
|
||||
if (value is String) {
|
||||
descending = value == '-1';
|
||||
else if (value is num) descending = value.toInt() == -1;
|
||||
} else if (value is num) descending = value.toInt() == -1;
|
||||
query.orderBy(key.toString(), descending: descending);
|
||||
});
|
||||
} else if (v is String) {
|
||||
|
@ -120,8 +120,7 @@ class OrmService<Id, Data, TQuery extends Query<Data, QueryWhere>>
|
|||
await _applyQuery(query, params);
|
||||
var result = await query.getOne(executor);
|
||||
if (result != null) return result;
|
||||
throw new AngelHttpException.notFound(
|
||||
message: 'No record found for ID $id');
|
||||
throw AngelHttpException.notFound(message: 'No record found for ID $id');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -133,7 +132,7 @@ class OrmService<Id, Data, TQuery extends Query<Data, QueryWhere>>
|
|||
await _applyQuery(query, params);
|
||||
var result = await query.getOne(executor);
|
||||
if (result != null) return result;
|
||||
throw new AngelHttpException.notFound(message: errorMessage);
|
||||
throw AngelHttpException.notFound(message: errorMessage);
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -170,8 +169,7 @@ class OrmService<Id, Data, TQuery extends Query<Data, QueryWhere>>
|
|||
|
||||
var result = await query.updateOne(executor);
|
||||
if (result != null) return result;
|
||||
throw new AngelHttpException.notFound(
|
||||
message: 'No record found for ID $id');
|
||||
throw AngelHttpException.notFound(message: 'No record found for ID $id');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -192,7 +190,6 @@ class OrmService<Id, Data, TQuery extends Query<Data, QueryWhere>>
|
|||
|
||||
var result = await query.deleteOne(executor);
|
||||
if (result != null) return result;
|
||||
throw new AngelHttpException.notFound(
|
||||
message: 'No record found for ID $id');
|
||||
throw AngelHttpException.notFound(message: 'No record found for ID $id');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,4 +23,7 @@ dev_dependencies:
|
|||
logging: ^0.11.0
|
||||
pedantic: ^1.0.0
|
||||
postgres: ^1.0.0
|
||||
test: ^1.0.0
|
||||
test: ^1.0.0
|
||||
dependency_overrides:
|
||||
angel_migration:
|
||||
path: ../angel_migration
|
|
@ -238,7 +238,7 @@ class Pokemon extends _Pokemon {
|
|||
PokemonType type2,
|
||||
DateTime createdAt,
|
||||
DateTime updatedAt}) {
|
||||
return new Pokemon(
|
||||
return Pokemon(
|
||||
id: id ?? this.id,
|
||||
species: species ?? this.species,
|
||||
name: name ?? this.name,
|
||||
|
@ -281,7 +281,7 @@ class Pokemon extends _Pokemon {
|
|||
// SerializerGenerator
|
||||
// **************************************************************************
|
||||
|
||||
const PokemonSerializer pokemonSerializer = const PokemonSerializer();
|
||||
const PokemonSerializer pokemonSerializer = PokemonSerializer();
|
||||
|
||||
class PokemonEncoder extends Converter<Pokemon, Map> {
|
||||
const PokemonEncoder();
|
||||
|
@ -306,18 +306,18 @@ class PokemonSerializer extends Codec<Pokemon, Map> {
|
|||
get decoder => const PokemonDecoder();
|
||||
static Pokemon fromMap(Map map) {
|
||||
if (map['species'] == null) {
|
||||
throw new FormatException("Missing required field 'species' on Pokemon.");
|
||||
throw FormatException("Missing required field 'species' on Pokemon.");
|
||||
}
|
||||
|
||||
if (map['level'] == null) {
|
||||
throw new FormatException("Missing required field 'level' on Pokemon.");
|
||||
throw FormatException("Missing required field 'level' on Pokemon.");
|
||||
}
|
||||
|
||||
if (map['type1'] == null) {
|
||||
throw new FormatException("Missing required field 'type1' on Pokemon.");
|
||||
throw FormatException("Missing required field 'type1' on Pokemon.");
|
||||
}
|
||||
|
||||
return new Pokemon(
|
||||
return Pokemon(
|
||||
id: map['id'] as String,
|
||||
species: map['species'] as String,
|
||||
name: map['name'] as String,
|
||||
|
@ -349,15 +349,15 @@ class PokemonSerializer extends Codec<Pokemon, Map> {
|
|||
return null;
|
||||
}
|
||||
if (model.species == null) {
|
||||
throw new FormatException("Missing required field 'species' on Pokemon.");
|
||||
throw FormatException("Missing required field 'species' on Pokemon.");
|
||||
}
|
||||
|
||||
if (model.level == null) {
|
||||
throw new FormatException("Missing required field 'level' on Pokemon.");
|
||||
throw FormatException("Missing required field 'level' on Pokemon.");
|
||||
}
|
||||
|
||||
if (model.type1 == null) {
|
||||
throw new FormatException("Missing required field 'type1' on Pokemon.");
|
||||
throw FormatException("Missing required field 'type1' on Pokemon.");
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -2,13 +2,12 @@ import 'package:angel_migration/angel_migration.dart';
|
|||
import 'package:angel_model/angel_model.dart';
|
||||
import 'package:angel_orm/angel_orm.dart';
|
||||
import 'package:angel_serialize/angel_serialize.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'car.dart';
|
||||
// import 'car.dart';
|
||||
part 'has_car.g.dart';
|
||||
|
||||
Map _carToMap(Car car) => car.toJson();
|
||||
// Map _carToMap(Car car) => car.toJson();
|
||||
|
||||
Car _carFromMap(map) => CarSerializer.fromMap(map as Map);
|
||||
// Car _carFromMap(map) => CarSerializer.fromMap(map as Map);
|
||||
|
||||
enum CarType { sedan, suv, atv }
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ import 'package:angel_serialize/angel_serialize.dart';
|
|||
import 'package:collection/collection.dart';
|
||||
part 'has_map.g.dart';
|
||||
|
||||
String _boolToCustom(bool v) => v ? 'yes' : 'no';
|
||||
bool _customToBool(v) => v == 'yes';
|
||||
// String _boolToCustom(bool v) => v ? 'yes' : 'no';
|
||||
// bool _customToBool(v) => v == 'yes';
|
||||
|
||||
@orm
|
||||
@serializable
|
||||
|
|
Loading…
Reference in a new issue