Skip to content

Commit

Permalink
Rearrange logic
Browse files Browse the repository at this point in the history
to streamline checks for CAST,
  • Loading branch information
griffio committed Sep 18, 2023
1 parent d5884ee commit 715a959
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,14 @@ internal fun SqlExpr.argumentType(argument: SqlExpr): IntermediateType {
}

is SqlBinaryExpr -> {
val validArg = children.lastOrNull { it is SqlCastExpr && it == argument } ?: if (children.none() { it is SqlColumnExpr }) {
parent.children.lastOrNull { it is SqlExpr && it !== argument && it !is SqlBinaryExpr }
} else {
children.lastOrNull { it is SqlExpr && it !== argument && it !is SqlBindExpr }
val validArg = children.lastOrNull {
it is SqlCastExpr && it == argument
} ?: children.lastOrNull {
it is SqlColumnExpr
} ?: parent.children.lastOrNull {
it is SqlExpr && it !== argument && it !is SqlBinaryExpr
}

validArg?.type() ?: children.last { it is SqlExpr && it !== argument }.type()
}

Expand Down

0 comments on commit 715a959

Please sign in to comment.