com.sxtanna.db.struct.statement.select.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Kuery Show documentation
Show all versions of Kuery Show documentation
MySQL Kotlin DSL/ORM based on HikariCP
package com.sxtanna.db.struct.statement
import com.sxtanna.db.struct.Table
import com.sxtanna.db.struct.base.Order.Direction
import com.sxtanna.db.struct.base.Order.Direction.ASCEND
import com.sxtanna.db.struct.base.Order.Direction.DESCEND
import com.sxtanna.db.struct.base.Where
import kotlin.reflect.KProperty1
/**
* Describes an SQL "SELECT" statement for one column
*/
interface Select1 {
/**
* The first component result of this "SELECT" statement
*/
operator fun component1() : R1
/**
* Define the "ORDER BY" clauses for the returned results
*/
fun order(prop : KProperty1, direction : Direction = ASCEND) : Select1
/**
* Define the "WHERE" clauses for this statement
*/
fun where(prop : KProperty1, block : Where.(KProperty1) -> Unit) : Select1
/**
* Shorthand for defining "Ascending" ordering
*/
fun ascend(prop : KProperty1) = order(prop, ASCEND)
/**
* Shorthand for defining "Descending" ordering
*/
fun descend(prop : KProperty1) = order(prop, DESCEND)
}
/**
* Describes an SQL "SELECT" statement for two columns
*/
interface Select2 : Select1 {
/**
* The second component result of this "SELECT" statement
*/
operator fun component2() : R2
override fun order(prop : KProperty1, direction : Direction) : Select2
override fun where(prop : KProperty1, block : Where.(KProperty1) -> Unit) : Select2
}
/**
* Describes an SQL "SELECT" statement for three columns
*/
interface Select3 : Select2 {
/**
* The third component result of this "SELECT" statement
*/
operator fun component3() : R3
override fun order(prop : KProperty1, direction : Direction) : Select3
override fun where(prop : KProperty1, block : Where.(KProperty1) -> Unit) : Select3
}
/**
* Describes an SQL "SELECT" statement for four columns
*/
interface Select4 : Select3 {
/**
* The fourth component result of this "SELECT" statement
*/
operator fun component4() : R4
override fun order(prop : KProperty1, direction : Direction) : Select4
override fun where(prop : KProperty1, block : Where.(KProperty1) -> Unit) : Select4
}
/**
* Describes an SQL "SELECT" statement for five columns
*/
interface Select5 : Select4 {
/**
* The fifth component result of this "SELECT" statement
*/
operator fun component5() : R5
override fun order(prop : KProperty1, direction : Direction) : Select5
override fun where(prop : KProperty1, block : Where.(KProperty1) -> Unit) : Select5
}
/**
* An object that can select rows and columns from a table
*/
interface Selector {
/**
* Select all rows from the table
* * Destructs to a list of [E]
*/
fun select(table : Table) : Select1>
/**
* Select [R1] rows from the table
* * Destructs to a list of [R1]
*/
fun
select(table : Table,
prop : KProperty1) : Select1>
/**
* Select [R1] and [R2] rows from the table
* * Destructs to lists of [R1] and [R2]
*/
fun
select(table : Table,
prop1 : KProperty1,
prop2 : KProperty1) : Select2, List>
/**
* Select [R1], [R2], and [R3] rows from the table
* * Destructs to lists of [R1], [R2], and [R3]
*/
fun
select(table : Table,
prop1 : KProperty1,
prop2 : KProperty1,
prop3 : KProperty1) : Select3, List, List>
/**
* Select [R1], [R2], [R3], and [R4] rows from the table
* * Destructs to lists of [R1], [R2], [R3], and [R4]
*/
fun
select(table : Table,
prop1 : KProperty1,
prop2 : KProperty1,
prop3 : KProperty1,
prop4 : KProperty1) : Select4, List, List, List>
/**
* Select [R1], [R2], [R3], [R4] and [R5] rows from the table
* * Destructs to lists of [R1], [R2], [R3], [R4], and [R5]
*/
fun
select(table : Table,
prop1 : KProperty1,
prop2 : KProperty1,
prop3 : KProperty1,
prop4 : KProperty1,
prop5 : KProperty1) : Select5, List, List, List, List>
/**
* An object that can select rows and columns from its table
*/
interface TableSelector {
/**
* Select all rows from the table
* * Destructs to a list of [E]
*/
fun select() : Select1>
/**
* Select [R1] rows from the table
* * Destructs to a list of [R1]
*/
fun
select(prop : KProperty1) : Select1>
/**
* Select [R1] and [R2] rows from the table
* * Destructs to lists of [R1] and [R2]
*/
fun
select(prop1 : KProperty1,
prop2 : KProperty1) : Select2, List>
/**
* Select [R1], [R2], and [R3] rows from the table
* * Destructs to lists of [R1], [R2], and [R3]
*/
fun
select(prop1 : KProperty1,
prop2 : KProperty1,
prop3 : KProperty1) : Select3, List, List>
/**
* Select [R1], [R2], [R3], and [R4] rows from the table
* * Destructs to lists of [R1], [R2], [R3], and [R4]
*/
fun
select(prop1 : KProperty1,
prop2 : KProperty1,
prop3 : KProperty1,
prop4 : KProperty1) : Select4, List, List, List>
/**
* Select [R1], [R2], [R3], [R4] and [R5] rows from the table
* * Destructs to lists of [R1], [R2], [R3], [R4], and [R5]
*/
fun
select(prop1 : KProperty1,
prop2 : KProperty1,
prop3 : KProperty1,
prop4 : KProperty1,
prop5 : KProperty1) : Select5, List, List, List, List>
}
}