-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for non-fallthrough null operations in map/flatMap/exists
- Loading branch information
1 parent
0f1c2d1
commit 701d7ea
Showing
36 changed files
with
1,046 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package io.getquill.ast | ||
|
||
object Implicits { | ||
implicit class AstOpsExt(body: Ast) { | ||
def +||+(other: Ast) = BinaryOperation(body, BooleanOperator.`||`, other) | ||
def +&&+(other: Ast) = BinaryOperation(body, BooleanOperator.`&&`, other) | ||
def +==+(other: Ast) = BinaryOperation(body, EqualityOperator.`==`, other) | ||
} | ||
} | ||
|
||
object +||+ { | ||
def unapply(a: Ast): Option[(Ast, Ast)] = { | ||
a match { | ||
case BinaryOperation(one, BooleanOperator.`||`, two) => Some((one, two)) | ||
case _ => None | ||
} | ||
} | ||
} | ||
|
||
object +&&+ { | ||
def unapply(a: Ast): Option[(Ast, Ast)] = { | ||
a match { | ||
case BinaryOperation(one, BooleanOperator.`&&`, two) => Some((one, two)) | ||
case _ => None | ||
} | ||
} | ||
} | ||
|
||
object +==+ { | ||
def unapply(a: Ast): Option[(Ast, Ast)] = { | ||
a match { | ||
case BinaryOperation(one, EqualityOperator.`==`, two) => Some((one, two)) | ||
case _ => None | ||
} | ||
} | ||
} | ||
|
||
object IsNotNullCheck { | ||
def apply(ast: Ast) = BinaryOperation(ast, EqualityOperator.`!=`, NullValue) | ||
|
||
def unapply(ast: Ast): Option[Ast] = { | ||
ast match { | ||
case BinaryOperation(cond, EqualityOperator.`!=`, NullValue) => Some(cond) | ||
case _ => None | ||
} | ||
} | ||
} | ||
|
||
object IsNullCheck { | ||
def apply(ast: Ast) = BinaryOperation(ast, EqualityOperator.`==`, NullValue) | ||
|
||
def unapply(ast: Ast): Option[Ast] = { | ||
ast match { | ||
case BinaryOperation(cond, EqualityOperator.`==`, NullValue) => Some(cond) | ||
case _ => None | ||
} | ||
} | ||
} | ||
|
||
object IfExistElseNull { | ||
def apply(exists: Ast, `then`: Ast) = | ||
If(IsNotNullCheck(exists), `then`, NullValue) | ||
|
||
def unapply(ast: Ast) = ast match { | ||
case If(IsNotNullCheck(exists), t, NullValue) => Some((exists, t)) | ||
case _ => None | ||
} | ||
} | ||
|
||
object IfExist { | ||
def apply(exists: Ast, `then`: Ast, otherwise: Ast) = | ||
If(IsNotNullCheck(exists), `then`, otherwise) | ||
|
||
def unapply(ast: Ast) = ast match { | ||
case If(IsNotNullCheck(exists), t, e) => Some((exists, t, e)) | ||
case _ => None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.