Skip to content

Commit

Permalink
inList with Pair and Triple support
Browse files Browse the repository at this point in the history
#643 / Formatting
  • Loading branch information
Tapac committed Apr 25, 2021
1 parent f1adac4 commit 26c90a4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,15 @@ interface ISqlExpressionBuilder {
* Checks if both expressions are equal to elements from [list].
* Doesn't supported by SQLite
**/
infix fun <T1, T2> Pair<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>>.inList(list: Iterable<Pair<T1, T2>>): InListOrNotInListBaseOp<Pair<T1, T2>>
= PairInListOp(this, list, isInList = true)
infix fun <T1, T2> Pair<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>>.inList(list: Iterable<Pair<T1, T2>>): InListOrNotInListBaseOp<Pair<T1, T2>> =
PairInListOp(this, list, isInList = true)

/**
* Checks if expressions from triple are equal to elements from [list].
* Doesn't supported by SQLite
**/
infix fun <T1, T2, T3> Triple<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>, ExpressionWithColumnType<T3>>.inList(list: Iterable<Triple<T1, T2, T3>>): InListOrNotInListBaseOp<Triple<T1, T2, T3>>
= TripleInListOp(this, list, isInList = true)
infix fun <T1, T2, T3> Triple<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>, ExpressionWithColumnType<T3>>.inList(list: Iterable<Triple<T1, T2, T3>>): InListOrNotInListBaseOp<Triple<T1, T2, T3>> =
TripleInListOp(this, list, isInList = true)

/** Checks if this expression is equals to any element from [list]. */
@Suppress("UNCHECKED_CAST")
Expand All @@ -373,15 +373,15 @@ interface ISqlExpressionBuilder {
* Checks if both expressions are not equal to elements from [list].
* Doesn't supported by SQLite
**/
infix fun <T1, T2> Pair<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>>.notInList(list: Iterable<Pair<T1, T2>>): InListOrNotInListBaseOp<Pair<T1, T2>>
= PairInListOp(this, list, isInList = false)
infix fun <T1, T2> Pair<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>>.notInList(list: Iterable<Pair<T1, T2>>): InListOrNotInListBaseOp<Pair<T1, T2>> =
PairInListOp(this, list, isInList = false)

/**
* Checks if expressions from triple are not equal to elements from [list].
* Doesn't supported by SQLite
**/
infix fun <T1, T2, T3> Triple<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>, ExpressionWithColumnType<T3>>.notInList(list: Iterable<Triple<T1, T2, T3>>): InListOrNotInListBaseOp<Triple<T1, T2, T3>>
= TripleInListOp(this, list, isInList = false)
infix fun <T1, T2, T3> Triple<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>, ExpressionWithColumnType<T3>>.notInList(list: Iterable<Triple<T1, T2, T3>>): InListOrNotInListBaseOp<Triple<T1, T2, T3>> =
TripleInListOp(this, list, isInList = false)

/** Checks if this expression is not equals to any element from [list]. */
@Suppress("UNCHECKED_CAST")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ abstract class InListOrNotInListBaseOp<V> (
}

class SingleValueInListOp<T>(
expr : ExpressionWithColumnType<T>,
expr: ExpressionWithColumnType<T>,
list: Iterable<T>,
isInList: Boolean = true
) : InListOrNotInListBaseOp<T>(expr, list, isInList) {
Expand All @@ -82,7 +82,7 @@ class SingleValueInListOp<T>(
}

class PairInListOp<T1, T2>(
expr : Pair<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>>,
expr: Pair<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>>,
list: Iterable<Pair<T1, T2>>,
isInList: Boolean = true
) : InListOrNotInListBaseOp<Pair<T1, T2>>(expr, list, isInList) {
Expand All @@ -92,11 +92,11 @@ class PairInListOp<T1, T2>(
}

class TripleInListOp<T1, T2, T3>(
expr : Triple<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>, ExpressionWithColumnType<T3>>,
expr: Triple<ExpressionWithColumnType<T1>, ExpressionWithColumnType<T2>, ExpressionWithColumnType<T3>>,
list: Iterable<Triple<T1, T2, T3>>,
isInList: Boolean = true
) : InListOrNotInListBaseOp<Triple<T1, T2, T3>>(expr, list, isInList) {
override val columnTypes: List<ExpressionWithColumnType<*>> = listOf(expr.first, expr.second, expr.third)

override fun extractValues(value: Triple<T1, T2, T3>): List<Any?> = listOf(value.first, value.second, value.third)
}
}

0 comments on commit 26c90a4

Please sign in to comment.