Skip to content

Commit 84bbe4a

Browse files
Add infix function for PropertyQueryCondition.alias(name).
1 parent 773098e commit 84bbe4a

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2020 ObjectBox Ltd. All rights reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.objectbox.kotlin
18+
19+
import io.objectbox.query.PropertyQueryCondition
20+
import io.objectbox.query.QueryCondition
21+
22+
23+
/**
24+
* Assigns an alias to this condition that can later be used with the [io.objectbox.query.Query] setParameter methods.
25+
*/
26+
infix fun <T> PropertyQueryCondition<T>.alias(name: String): QueryCondition<T> {
27+
return alias(name)
28+
}

tests/objectbox-java-test/src/test/java/io/objectbox/query/QueryTestK.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class QueryTestK : AbstractQueryTest() {
8181

8282
val valuesInt = intArrayOf(1, 1, 2, 3, 2003, 2007, 2002, -1)
8383
val query = box.query(
84-
(TestEntity_.simpleInt oneOf(valuesInt)).alias("int")
84+
TestEntity_.simpleInt oneOf(valuesInt) alias "int"
8585
).build()
8686
assertEquals(3, query.count())
8787

0 commit comments

Comments
 (0)