-
-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8934336
commit 3bf7c08
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
...m-ksp-compiler/src/test/kotlin/org/ktorm/ksp/compiler/generator/RefsClassGeneratorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.ktorm.ksp.compiler.generator | ||
|
||
import org.junit.Test | ||
import org.ktorm.ksp.compiler.BaseKspTest | ||
|
||
/** | ||
* Created by vince at Jul 16, 2023. | ||
*/ | ||
class RefsClassGeneratorTest : BaseKspTest() { | ||
|
||
@Test | ||
fun testRefs() = runKotlin( | ||
""" | ||
@Table | ||
interface Employee: Entity<Employee> { | ||
@PrimaryKey | ||
var id: Int | ||
var name: String | ||
var job: String | ||
var managerId: Int? | ||
var hireDate: LocalDate | ||
var salary: Long | ||
@References | ||
var department: Department | ||
} | ||
@Table | ||
interface Department: Entity<Department> { | ||
@PrimaryKey | ||
var id: Int | ||
var name: String | ||
var location: String | ||
} | ||
fun run() { | ||
val employees = database.employees | ||
.filter { it.refs.department.name eq "tech" } | ||
.filter { it.refs.department.location eq "Guangzhou" } | ||
.sortedBy { it.id } | ||
.toList() | ||
assert(employees.size == 2) | ||
assert(employees[0].name == "vince") | ||
assert(employees[1].name == "marry") | ||
} | ||
""".trimIndent()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
drop table if exists "user"; | ||
drop table if exists "employee"; | ||
drop table if exists "department"; | ||
drop table if exists "province"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters