mirror of https://github.com/AMT-Cheif/drift.git
Merge pull request #2814 from tt88dev/bugfix/max-and-min-string
[bugfix/max_and_min_string]
This commit is contained in:
commit
379b92d09c
|
@ -20,3 +20,4 @@ docs/**/*.g.dart
|
|||
*/build/
|
||||
drift/extension/devtools/build
|
||||
**/pubspec_overrides.yaml
|
||||
**.history/
|
|
@ -30,6 +30,20 @@ extension BaseAggregate<DT extends Object> on Expression<DT> {
|
|||
filter: filter, distinct: distinct);
|
||||
}
|
||||
|
||||
/// Return the maximum of all non-null values in this group.
|
||||
///
|
||||
/// If there are no non-null values in the group, returns null.
|
||||
/// {@macro drift_aggregate_filter}
|
||||
Expression<DT> max({Expression<bool>? filter}) =>
|
||||
_AggregateExpression('MAX', [this], filter: filter);
|
||||
|
||||
/// Return the minimum of all non-null values in this group.
|
||||
///
|
||||
/// If there are no non-null values in the group, returns null.
|
||||
/// {@macro drift_aggregate_filter}
|
||||
Expression<DT> min({Expression<bool>? filter}) =>
|
||||
_AggregateExpression('MIN', [this], filter: filter);
|
||||
|
||||
/// Returns the concatenation of all non-null values in the current group,
|
||||
/// joined by the [separator].
|
||||
///
|
||||
|
|
|
@ -5,6 +5,7 @@ import '../../test_utils/test_utils.dart';
|
|||
|
||||
void main() {
|
||||
const foo = CustomExpression<int>('foo', precedence: Precedence.primary);
|
||||
const s1 = CustomExpression<String>('s1', precedence: Precedence.primary);
|
||||
|
||||
group('count', () {
|
||||
test('all', () {
|
||||
|
@ -49,10 +50,12 @@ void main() {
|
|||
|
||||
test('max', () {
|
||||
expect(foo.max(), generates('MAX(foo)'));
|
||||
expect(s1.max(), generates('MAX(s1)'));
|
||||
});
|
||||
|
||||
test('min', () {
|
||||
expect(foo.min(), generates('MIN(foo)'));
|
||||
expect(s1.min(), generates('MIN(s1)'));
|
||||
});
|
||||
|
||||
test('sum', () {
|
||||
|
|
Loading…
Reference in New Issue