@@ -143,9 +143,15 @@ class KMariaDBTest {
143143 }
144144 }
145145
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)
149155
150156 @Test
151157 fun testIsLikeEscape () {
@@ -154,7 +160,7 @@ class KMariaDBTest {
154160 val selectStatement = select(id, description) {
155161 from(items)
156162 where {
157- description(KIsLikeEscape . isLike(" Item 1%" , ' #' ))
163+ description(isLike(" Item 1%" , ' #' ))
158164 }
159165 }
160166
@@ -171,7 +177,7 @@ class KMariaDBTest {
171177 val selectStatement = select(id, description) {
172178 from(items)
173179 where {
174- description(KIsLikeEscape . isLike(" %fred%" ))
180+ description(isLike(" %fred%" ))
175181 }
176182 }
177183
@@ -184,7 +190,7 @@ class KMariaDBTest {
184190 val selectStatement = select(id, description) {
185191 from(items)
186192 where {
187- description(KIsLikeEscape . isLike(" %fred%" , ' #' ).map { s -> s.uppercase(Locale .getDefault()) })
193+ description(isLike(" %fred%" , ' #' ).map { s -> s.uppercase(Locale .getDefault()) })
188194 }
189195 }
190196
@@ -197,7 +203,7 @@ class KMariaDBTest {
197203 val selectStatement = select(id, description) {
198204 from(items)
199205 where {
200- description(KIsLikeEscape . isLike(" %fred%" , ' #' ).filter { _ -> false })
206+ description(isLike(" %fred%" , ' #' ).filter { _ -> false })
201207 }
202208 configureStatement { isNonRenderingWhereClauseAllowed = true }
203209 }
@@ -211,7 +217,7 @@ class KMariaDBTest {
211217 val selectStatement = select(id, description) {
212218 from(items)
213219 where {
214- description(KIsLikeEscape . isLike(" %fred%" , ' #' )
220+ description(isLike(" %fred%" , ' #' )
215221 .filter { _ -> true }
216222 .map { s -> s.uppercase(Locale .getDefault()) }
217223 .filter{_ -> false })
0 commit comments