Format, fix typos

This commit is contained in:
Simon Binder 2019-02-05 21:39:40 +01:00
parent e66fb0702c
commit d984f93c3a
4 changed files with 18 additions and 6 deletions

View File

@ -5,6 +5,9 @@ import 'package:sally/src/runtime/sql_types.dart';
Expression<BoolType> and(Expression<BoolType> a, Expression<BoolType> b) =>
AndExpression(a, b);
Expression<BoolType> or(Expression<BoolType> a, Expression<BoolType> b) =>
OrExpression(a, b);
Expression<BoolType> not(Expression<BoolType> a) => NotExpression(a);
class AndExpression extends Expression<BoolType> with InfixOperator<BoolType> {
@ -22,7 +25,7 @@ class OrExpression extends Expression<BoolType> with InfixOperator<BoolType> {
Expression<BoolType> left, right;
@override
final String operator = 'AND';
final String operator = 'OR';
OrExpression(this.left, this.right);
}

View File

@ -1 +1 @@
export 'bools.dart' show and, not;
export 'bools.dart' show and, or, not;

View File

@ -46,7 +46,7 @@ void main() {
['Dash', 12]));
});
test('generates expressions from boolean fields', () {
test('generates expressions from boolean columns', () {
(db.select(db.users)..where((u) => u.isAwesome)).get();
verify(executor.runSelect(
@ -54,12 +54,22 @@ void main() {
});
});
group('Generates DELETE statements', () {
test('without any constraints', () {
db.delete(db.users).go();
verify(executor.runDelete('DELETE FROM users;', argThat(isEmpty)));
});
test('for complex components', () {
(db.delete(db.users)
..where((u) => or(not(u.isAwesome), u.id.isSmallerThan(100)))
..limit(10, offset: 100))
.go();
verify(executor.runDelete(
'DELETE FROM users WHERE (NOT (is_awesome = 1)) OR (id < ?) LIMIT 10, 100;',
[100]));
});
});
}

View File

@ -5,8 +5,7 @@ class SallyError {
final String message;
final Element affectedElement;
SallyError(
{this.critical = false, this.message, this.affectedElement});
SallyError({this.critical = false, this.message, this.affectedElement});
}
class ErrorStore {