mirror of https://github.com/AMT-Cheif/drift.git
Bugfix feature - String columns to support MAX and MIN
This commit is contained in:
parent
f9fa123e4a
commit
0264a8fbe1
|
@ -20,3 +20,4 @@ docs/**/*.g.dart
|
||||||
*/build/
|
*/build/
|
||||||
drift/extension/devtools/build
|
drift/extension/devtools/build
|
||||||
**/pubspec_overrides.yaml
|
**/pubspec_overrides.yaml
|
||||||
|
**.history/
|
|
@ -30,6 +30,20 @@ extension BaseAggregate<DT extends Object> on Expression<DT> {
|
||||||
filter: filter, distinct: distinct);
|
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,
|
/// Returns the concatenation of all non-null values in the current group,
|
||||||
/// joined by the [separator].
|
/// joined by the [separator].
|
||||||
///
|
///
|
||||||
|
|
|
@ -5,6 +5,7 @@ import '../../test_utils/test_utils.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
const foo = CustomExpression<int>('foo', precedence: Precedence.primary);
|
const foo = CustomExpression<int>('foo', precedence: Precedence.primary);
|
||||||
|
const s1 = CustomExpression<String>('s1', precedence: Precedence.primary);
|
||||||
|
|
||||||
group('count', () {
|
group('count', () {
|
||||||
test('all', () {
|
test('all', () {
|
||||||
|
@ -49,10 +50,12 @@ void main() {
|
||||||
|
|
||||||
test('max', () {
|
test('max', () {
|
||||||
expect(foo.max(), generates('MAX(foo)'));
|
expect(foo.max(), generates('MAX(foo)'));
|
||||||
|
expect(s1.max(), generates('MAX(s1)'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('min', () {
|
test('min', () {
|
||||||
expect(foo.min(), generates('MIN(foo)'));
|
expect(foo.min(), generates('MIN(foo)'));
|
||||||
|
expect(s1.min(), generates('MIN(s1)'));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('sum', () {
|
test('sum', () {
|
||||||
|
|
Loading…
Reference in New Issue