mirror of https://github.com/AMT-Cheif/drift.git
Move nullIf into expression class
This commit is contained in:
parent
41395abe3f
commit
87d0ca3c4e
|
@ -165,6 +165,11 @@ abstract class Expression<D extends Object> implements FunctionParameter {
|
||||||
return FunctionCallExpression<T>('IIF', [predicate, this, ifFalse]);
|
return FunctionCallExpression<T>('IIF', [predicate, this, ifFalse]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `null` if [matcher] is equal to this expression, `this` otherwise.
|
||||||
|
Expression<D> nullIf(Expression<D> matcher) {
|
||||||
|
return FunctionCallExpression('NULLIF', [this, matcher]);
|
||||||
|
}
|
||||||
|
|
||||||
/// Writes this expression into the [GenerationContext], assuming that there's
|
/// Writes this expression into the [GenerationContext], assuming that there's
|
||||||
/// an outer expression with [precedence]. If the [Expression.precedence] of
|
/// an outer expression with [precedence]. If the [Expression.precedence] of
|
||||||
/// `this` expression is lower, it will be wrap}ped in
|
/// `this` expression is lower, it will be wrap}ped in
|
||||||
|
|
|
@ -36,14 +36,6 @@ Expression<T> ifNull<T extends Object>(
|
||||||
return FunctionCallExpression<T>('IFNULL', [first, second]);
|
return FunctionCallExpression<T>('IFNULL', [first, second]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extension defines the `nullIf` members.
|
|
||||||
extension SqlNullIf on Expression {
|
|
||||||
/// Returns null if both [matcher] matches this expression.
|
|
||||||
Expression nullIf(Expression matcher) {
|
|
||||||
return FunctionCallExpression('NULLIF', [this, matcher]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class _NullCheck extends Expression<bool> {
|
class _NullCheck extends Expression<bool> {
|
||||||
final Expression _inner;
|
final Expression _inner;
|
||||||
final bool _isNull;
|
final bool _isNull;
|
||||||
|
|
Loading…
Reference in New Issue