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