Skip to content

Commit ddc7ac4

Browse files
sschuberthEtsija
authored andcommitted
feat(dao): Add case-insensitive regex-operators
Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent 4aea7cb commit ddc7ac4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

dao/src/main/kotlin/utils/Extensions.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,12 @@ class InsensitiveLikeOp(expr1: Expression<*>, expr2: Expression<*>) : Comparison
233233
*/
234234
class RegexOp(expr1: Expression<*>, expr2: Expression<*>) : ComparisonOp(expr1, expr2, "~")
235235

236+
/**
237+
* Represents a case-insensitive regex operation. This is an extension of the [ComparisonOp] class that uses the ~*
238+
* operator.
239+
*/
240+
class InsensitiveRegexOp(expr1: Expression<*>, expr2: Expression<*>) : ComparisonOp(expr1, expr2, "~*")
241+
236242
/**
237243
* Apply the given [value] to filter this column by using the ILIKE operator.
238244
*/
@@ -245,6 +251,12 @@ fun Expression<String>.applyILike(value: String): Op<Boolean> =
245251
fun Expression<String>.applyRegex(value: String): Op<Boolean> =
246252
RegexOp(this, QueryParameter(value, TextColumnType()))
247253

254+
/**
255+
* Apply the given [value] to filter this column by using the ~* operator.
256+
*/
257+
fun Expression<String>.applyIRegex(value: String): Op<Boolean> =
258+
InsensitiveRegexOp(this, QueryParameter(value, TextColumnType()))
259+
248260
/**
249261
* Apply the given [operator] and filter [values] to filter this column by. This is an overload of the
250262
* applyFilter function for collections.

0 commit comments

Comments
 (0)