@@ -143,9 +143,15 @@ class KMariaDBTest {
143
143
}
144
144
}
145
145
146
- // Note that the following example uses of KIsLikeEscape are a bit awkward and don't look as natural as the
147
- // built-in conditions. We should be able to improve this once Kotlin implements the context parameters
148
- // proposal (https://github.com/Kotlin/KEEP/issues/367)
146
+
147
+ /* *
148
+ * Shortcut function for KIsLikeEscape
149
+ *
150
+ * Note that the following example uses of this function are a bit awkward and don't look as natural as the
151
+ * built-in conditions. We should be able to improve this once Kotlin implements the context parameters
152
+ * proposal (https://github.com/Kotlin/KEEP/issues/367)
153
+ */
154
+ fun <T : Any > isLike (value : T , escapeCharacter : Char? = null) = KIsLikeEscape .isLike(value, escapeCharacter)
149
155
150
156
@Test
151
157
fun testIsLikeEscape () {
@@ -154,7 +160,7 @@ class KMariaDBTest {
154
160
val selectStatement = select(id, description) {
155
161
from(items)
156
162
where {
157
- description(KIsLikeEscape . isLike(" Item 1%" , ' #' ))
163
+ description(isLike(" Item 1%" , ' #' ))
158
164
}
159
165
}
160
166
@@ -171,7 +177,7 @@ class KMariaDBTest {
171
177
val selectStatement = select(id, description) {
172
178
from(items)
173
179
where {
174
- description(KIsLikeEscape . isLike(" %fred%" ))
180
+ description(isLike(" %fred%" ))
175
181
}
176
182
}
177
183
@@ -184,7 +190,7 @@ class KMariaDBTest {
184
190
val selectStatement = select(id, description) {
185
191
from(items)
186
192
where {
187
- description(KIsLikeEscape . isLike(" %fred%" , ' #' ).map { s -> s.uppercase(Locale .getDefault()) })
193
+ description(isLike(" %fred%" , ' #' ).map { s -> s.uppercase(Locale .getDefault()) })
188
194
}
189
195
}
190
196
@@ -197,7 +203,7 @@ class KMariaDBTest {
197
203
val selectStatement = select(id, description) {
198
204
from(items)
199
205
where {
200
- description(KIsLikeEscape . isLike(" %fred%" , ' #' ).filter { _ -> false })
206
+ description(isLike(" %fred%" , ' #' ).filter { _ -> false })
201
207
}
202
208
configureStatement { isNonRenderingWhereClauseAllowed = true }
203
209
}
@@ -211,7 +217,7 @@ class KMariaDBTest {
211
217
val selectStatement = select(id, description) {
212
218
from(items)
213
219
where {
214
- description(KIsLikeEscape . isLike(" %fred%" , ' #' )
220
+ description(isLike(" %fred%" , ' #' )
215
221
.filter { _ -> true }
216
222
.map { s -> s.uppercase(Locale .getDefault()) }
217
223
.filter{_ -> false })
0 commit comments