[jOOQ/jOOQ#6256] Add jOOQ-kotlin
This commit includes a first draft of Extensions.kt to improve the Kotlin/jOOQ experience. More work to be added soon
This commit is contained in:
parent
5cc7164c76
commit
74fcb44060
@ -29,36 +29,40 @@
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Database access -->
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>${org.h2.version}</version>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-kotlin</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Needed for mapping into Kotlin data classes -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Database access -->
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
@ -105,7 +109,6 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>sql-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
|
||||
<configuration>
|
||||
<skip>${maven.test.skip}</skip>
|
||||
@ -145,7 +148,6 @@
|
||||
<plugin>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-codegen-maven</artifactId>
|
||||
<version>${project.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
@ -182,7 +184,6 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
|
||||
|
||||
|
||||
6
jOOQ-kotlin/.gitignore
vendored
Normal file
6
jOOQ-kotlin/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/target
|
||||
|
||||
/.cache
|
||||
|
||||
/.idea
|
||||
/*.iml
|
||||
19
jOOQ-kotlin/LICENSE.txt
Normal file
19
jOOQ-kotlin/LICENSE.txt
Normal file
@ -0,0 +1,19 @@
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Other licenses:
|
||||
-----------------------------------------------------------------------------
|
||||
Commercial licenses for this work are available. These replace the above
|
||||
ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
database integrations.
|
||||
|
||||
For more information, please visit: http://www.jooq.org/licenses
|
||||
10
jOOQ-kotlin/NOTICE.txt
Normal file
10
jOOQ-kotlin/NOTICE.txt
Normal file
@ -0,0 +1,10 @@
|
||||
Third party NOTICE.txt contents
|
||||
===============================
|
||||
|
||||
Contents of https://github.com/apache/commons-lang/blob/master/NOTICE.txt
|
||||
-------------------------------------------------------------------------
|
||||
Apache Commons Lang
|
||||
Copyright 2001-2019 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
80
jOOQ-kotlin/pom.xml
Normal file
80
jOOQ-kotlin/pom.xml
Normal file
@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-parent</artifactId>
|
||||
<version>3.14.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>jooq-kotlin</artifactId>
|
||||
<name>jOOQ Kotlin</name>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
</plugin>
|
||||
|
||||
<!-- The jar plugin -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>empty-javadoc-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<classifier>javadoc</classifier>
|
||||
<classesDirectory>${basedir}/javadoc</classesDirectory>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Automatic-Module-Name>org.jooq.kotlin</Automatic-Module-Name>
|
||||
</manifestEntries>
|
||||
</archive>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Needed for mapping into Kotlin data classes -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
336
jOOQ-kotlin/src/main/kotlin/org/jooq/kotlin/Extensions.kt
Normal file
336
jOOQ-kotlin/src/main/kotlin/org/jooq/kotlin/Extensions.kt
Normal file
@ -0,0 +1,336 @@
|
||||
package org.jooq.kotlin
|
||||
|
||||
import org.jooq.*
|
||||
import org.jooq.conf.Settings
|
||||
import org.jooq.impl.DSL
|
||||
import org.jooq.impl.DSL.field
|
||||
import java.util.*
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any, R: Record> Result<R>.into(): MutableList<T> {
|
||||
return this.into(T::class.java)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Class reification extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Field extensions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.`as`(alias: String): Field<T> {
|
||||
return field(this).`as`(alias);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.`as`(alias: Name): Field<T> {
|
||||
return field(this).`as`(alias);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.`as`(alias: Field<*>): Field<T> {
|
||||
return field(this).`as`(alias);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.eq(value: T): Condition {
|
||||
return field(this).eq(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.eq(value: Field<T>): Condition {
|
||||
return field(this).eq(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.eq(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).eq(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.eq(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).eq(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.equal(value: T): Condition {
|
||||
return field(this).equal(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.equal(value: Field<T>): Condition {
|
||||
return field(this).equal(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.equal(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).equal(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.equal(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).equal(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.ne(value: T): Condition {
|
||||
return field(this).ne(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.ne(value: Field<T>): Condition {
|
||||
return field(this).ne(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.ne(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).ne(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.ne(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).ne(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notEqual(value: T): Condition {
|
||||
return field(this).notEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notEqual(value: Field<T>): Condition {
|
||||
return field(this).notEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notEqual(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).notEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notEqual(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).notEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.gt(value: T): Condition {
|
||||
return field(this).gt(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.gt(value: Field<T>): Condition {
|
||||
return field(this).gt(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.gt(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).gt(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.gt(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).gt(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.greaterThan(value: T): Condition {
|
||||
return field(this).greaterThan(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.greaterThan(value: Field<T>): Condition {
|
||||
return field(this).greaterThan(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.greaterThan(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).greaterThan(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.greaterThan(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).greaterThan(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.ge(value: T): Condition {
|
||||
return field(this).ge(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.ge(value: Field<T>): Condition {
|
||||
return field(this).ge(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.ge(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).ge(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.ge(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).ge(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.greaterOrEqual(value: T): Condition {
|
||||
return field(this).greaterOrEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.greaterOrEqual(value: Field<T>): Condition {
|
||||
return field(this).greaterOrEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.greaterOrEqual(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).greaterOrEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.greaterOrEqual(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).greaterOrEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lt(value: T): Condition {
|
||||
return field(this).lt(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lt(value: Field<T>): Condition {
|
||||
return field(this).lt(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lt(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).lt(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lt(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).lt(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lessThan(value: T): Condition {
|
||||
return field(this).lessThan(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lessThan(value: Field<T>): Condition {
|
||||
return field(this).lessThan(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lessThan(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).lessThan(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lessThan(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).lessThan(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.le(value: T): Condition {
|
||||
return field(this).le(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.le(value: Field<T>): Condition {
|
||||
return field(this).le(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.le(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).le(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.le(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).le(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lessOrEqual(value: T): Condition {
|
||||
return field(this).lessOrEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lessOrEqual(value: Field<T>): Condition {
|
||||
return field(this).lessOrEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lessOrEqual(value: Select<out Record1<T>>): Condition {
|
||||
return field(this).lessOrEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.lessOrEqual(value: QuantifiedSelect<out Record1<T>>): Condition {
|
||||
return field(this).lessOrEqual(value);
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.asc(): SortField<T> {
|
||||
return field(this).asc();
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.desc(): SortField<T> {
|
||||
return field(this).desc();
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.`in`(values: Collection<*>): Condition {
|
||||
return field(this).`in`(values)
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.`in`(values: Result<out Record1<T>>): Condition {
|
||||
return field(this).`in`(values)
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.`in`(vararg values: T): Condition {
|
||||
return field(this).`in`(values.asList())
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.`in`(vararg values: Field<*>): Condition {
|
||||
return field(this).`in`(values.asList())
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.`in`(query: Select<out Record1<T>>): Condition {
|
||||
return field(this).`in`(query)
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notIn(values: Collection<*>): Condition {
|
||||
return field(this).notIn(values)
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notIn(values: Result<out Record1<T>>): Condition {
|
||||
return field(this).notIn(values)
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notIn(vararg values: T): Condition {
|
||||
return field(this).notIn(values.asList())
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notIn(vararg values: Field<*>): Condition {
|
||||
return field(this).notIn(values.asList())
|
||||
}
|
||||
|
||||
@Support
|
||||
inline fun <reified T: Any> Select<Record1<T>>.notIn(query: Select<out Record1<T>>): Condition {
|
||||
return field(this).notIn(query)
|
||||
}
|
||||
|
||||
19
jOOQ-kotlin/src/main/resources/META-INF/LICENSE.txt
Normal file
19
jOOQ-kotlin/src/main/resources/META-INF/LICENSE.txt
Normal file
@ -0,0 +1,19 @@
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
Other licenses:
|
||||
-----------------------------------------------------------------------------
|
||||
Commercial licenses for this work are available. These replace the above
|
||||
ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
database integrations.
|
||||
|
||||
For more information, please visit: http://www.jooq.org/licenses
|
||||
2
jOOQ-kotlin/src/main/resources/META-INF/README.txt
Normal file
2
jOOQ-kotlin/src/main/resources/META-INF/README.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Thanks for downloading jOOQ.
|
||||
Please visit http://www.jooq.org for more information.
|
||||
@ -0,0 +1,71 @@
|
||||
package org.jooq.kotlin
|
||||
|
||||
import org.jooq.SQLDialect
|
||||
import org.jooq.SQLDialect.H2
|
||||
import org.jooq.impl.DSL
|
||||
import org.jooq.impl.DSL.*
|
||||
import org.jooq.impl.SQLDataType
|
||||
import org.jooq.impl.SQLDataType.INTEGER
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.FixMethodOrder
|
||||
import org.junit.Test
|
||||
import org.junit.runners.MethodSorters
|
||||
|
||||
import kotlin.io.*
|
||||
|
||||
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
|
||||
class ExtensionsTest {
|
||||
|
||||
val i = field(unquotedName("i"), INTEGER)
|
||||
val j = field(unquotedName("j"), INTEGER)
|
||||
val dsl = DSL.using(H2)
|
||||
|
||||
@Test
|
||||
fun testScalarSubqueries() {
|
||||
assertEquals(field(select(i)).`as`("i"), select(i).`as`("i"))
|
||||
assertEquals(field(select(i)).`as`(name("i")), select(i).`as`(name("i")))
|
||||
assertEquals(field(select(i)).`as`(i), select(i).`as`(i))
|
||||
|
||||
assertEquals(field(select(i)).eq(1), select(i).eq(1))
|
||||
assertEquals(field(select(i)).eq(value(1)), select(i).eq(value(1)))
|
||||
assertEquals(field(select(i)).eq(select(value(1))), select(i).eq(select(value(1))))
|
||||
assertEquals(field(select(i)).eq(any(select(value(1)))), select(i).eq(any(select(value(1)))))
|
||||
|
||||
assertEquals(field(select(i)).ne(1), select(i).ne(1))
|
||||
assertEquals(field(select(i)).ne(value(1)), select(i).ne(value(1)))
|
||||
assertEquals(field(select(i)).ne(select(value(1))), select(i).ne(select(value(1))))
|
||||
assertEquals(field(select(i)).ne(any(select(value(1)))), select(i).ne(any(select(value(1)))))
|
||||
|
||||
assertEquals(field(select(i)).gt(1), select(i).gt(1))
|
||||
assertEquals(field(select(i)).gt(value(1)), select(i).gt(value(1)))
|
||||
assertEquals(field(select(i)).gt(select(value(1))), select(i).gt(select(value(1))))
|
||||
assertEquals(field(select(i)).gt(any(select(value(1)))), select(i).gt(any(select(value(1)))))
|
||||
|
||||
assertEquals(field(select(i)).ge(1), select(i).ge(1))
|
||||
assertEquals(field(select(i)).ge(value(1)), select(i).ge(value(1)))
|
||||
assertEquals(field(select(i)).ge(select(value(1))), select(i).ge(select(value(1))))
|
||||
assertEquals(field(select(i)).ge(any(select(value(1)))), select(i).ge(any(select(value(1)))))
|
||||
|
||||
assertEquals(field(select(i)).lt(1), select(i).lt(1))
|
||||
assertEquals(field(select(i)).lt(value(1)), select(i).lt(value(1)))
|
||||
assertEquals(field(select(i)).lt(select(value(1))), select(i).lt(select(value(1))))
|
||||
assertEquals(field(select(i)).lt(any(select(value(1)))), select(i).lt(any(select(value(1)))))
|
||||
|
||||
assertEquals(field(select(i)).le(1), select(i).le(1))
|
||||
assertEquals(field(select(i)).le(value(1)), select(i).le(value(1)))
|
||||
assertEquals(field(select(i)).le(select(value(1))), select(i).le(select(value(1))))
|
||||
assertEquals(field(select(i)).le(any(select(value(1)))), select(i).le(any(select(value(1)))))
|
||||
|
||||
assertEquals(field(select(i)).asc(), select(i).asc())
|
||||
assertEquals(field(select(i)).desc(), select(i).desc())
|
||||
|
||||
assertEquals(field(select(i)).`in`(1, 2), select(i).`in`(1, 2))
|
||||
assertEquals(field(select(i)).`in`(value(1), value(2)), select(i).`in`(value(1), value(2)))
|
||||
assertEquals(field(select(i)).`in`(select(value(1))), select(i).`in`(select(value(1))))
|
||||
|
||||
assertEquals(field(select(i)).notIn(1, 2), select(i).notIn(1, 2))
|
||||
assertEquals(field(select(i)).notIn(value(1), value(2)), select(i).notIn(value(1), value(2)))
|
||||
assertEquals(field(select(i)).notIn(select(value(1))), select(i).notIn(select(value(1))))
|
||||
}
|
||||
}
|
||||
40
jOOQ-kotlin/src/test/resources/db.sql
Normal file
40
jOOQ-kotlin/src/test/resources/db.sql
Normal file
@ -0,0 +1,40 @@
|
||||
DROP TABLE IF EXISTS t_book;
|
||||
DROP TABLE IF EXISTS t_author;
|
||||
DROP SEQUENCE IF EXISTS s_author_id;
|
||||
CREATE SEQUENCE s_author_id START WITH 1;
|
||||
|
||||
CREATE TABLE t_author (
|
||||
id INT NOT NULL,
|
||||
first_name VARCHAR(50),
|
||||
last_name VARCHAR(50) NOT NULL,
|
||||
date_of_birth DATE,
|
||||
year_of_birth INT,
|
||||
address VARCHAR(50),
|
||||
|
||||
CONSTRAINT pk_t_author PRIMARY KEY (ID)
|
||||
);
|
||||
|
||||
CREATE TABLE t_book (
|
||||
id INT NOT NULL,
|
||||
author_id INT NOT NULL,
|
||||
details_id INT,
|
||||
title VARCHAR(400) NOT NULL,
|
||||
published_in INT NOT NULL,
|
||||
language_id INT NOT NULL,
|
||||
content_text CLOB,
|
||||
content_pdf BLOB,
|
||||
|
||||
rec_version INT,
|
||||
rec_timestamp TIMESTAMP,
|
||||
|
||||
CONSTRAINT pk_t_book PRIMARY KEY (id),
|
||||
CONSTRAINT fk_t_book_author_id FOREIGN KEY (author_id) REFERENCES t_author(id)
|
||||
);
|
||||
|
||||
INSERT INTO t_author VALUES (next value for s_author_id, 'George', 'Orwell', '1903-06-25', 1903, null);
|
||||
INSERT INTO t_author VALUES (next value for s_author_id, 'Paulo', 'Coelho', '1947-08-24', 1947, null);
|
||||
|
||||
INSERT INTO t_book VALUES (1, 1, null, '1984', 1948, 1, 'To know and not to know, to be conscious of complete truthfulness while telling carefully constructed lies, to hold simultaneously two opinions which cancelled out, knowing them to be contradictory and believing in both of them, to use logic against logic, to repudiate morality while laying claim to it, to believe that democracy was impossible and that the Party was the guardian of democracy, to forget, whatever it was necessary to forget, then to draw it back into memory again at the moment when it was needed, and then promptly to forget it again, and above all, to apply the same process to the process itself -- that was the ultimate subtlety; consciously to induce unconsciousness, and then, once again, to become unconscious of the act of hypnosis you had just performed. Even to understand the word ''doublethink'' involved the use of doublethink..', null, 1, '2010-01-01 00:00:00');
|
||||
INSERT INTO t_book VALUES (2, 1, null, 'Animal Farm', 1945, 1, null, null, null, '2010-01-01 00:00:00');
|
||||
INSERT INTO t_book VALUES (3, 2, null, 'O Alquimista', 1988, 4, null, null, 1, null);
|
||||
INSERT INTO t_book VALUES (4, 2, null, 'Brida', 1990, 2, null, null, null, null);
|
||||
14
jOOQ-kotlin/src/test/resources/log4j2.xml
Normal file
14
jOOQ-kotlin/src/test/resources/log4j2.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="INFO">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{ABSOLUTE} %5p [%-50c{4}] - %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="Console"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
67
pom.xml
67
pom.xml
@ -36,6 +36,9 @@
|
||||
<jaxb.version>2.3.1</jaxb.version>
|
||||
<javax.activation.version>1.2.0</javax.activation.version>
|
||||
|
||||
<!-- Kotlin versions -->
|
||||
<kotlin.version>1.3.72</kotlin.version>
|
||||
|
||||
<!-- DefaultRecordMapper and jOOQ-meta-extensions can read JPA annotations -->
|
||||
<javax.persistence-api.version>2.2</javax.persistence-api.version>
|
||||
|
||||
@ -100,6 +103,30 @@
|
||||
<artifactId>jooq-meta-extensions</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-kotlin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Needed for mapping into Kotlin data classes -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-reflect</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.jooq</groupId>
|
||||
<artifactId>jooq-scala_2.13</artifactId>
|
||||
@ -463,6 +490,44 @@
|
||||
<version>4.3.0</version>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>${kotlin.version}</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>process-sources</phase>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sourceDirs>
|
||||
<source>src/main/java</source>
|
||||
<source>src/main/kotlin</source>
|
||||
<source>src/main/resources</source>
|
||||
</sourceDirs>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.eclipse.xtend</groupId>
|
||||
<artifactId>xtend-maven-plugin</artifactId>
|
||||
@ -533,13 +598,13 @@
|
||||
<module>jOOQ-meta-extensions</module>
|
||||
<module>jOOQ-codegen</module>
|
||||
<module>jOOQ-codegen-maven</module>
|
||||
<module>jOOQ-kotlin</module>
|
||||
<module>jOOQ-scala_2.13</module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<module>jOOQ-xtend</module>
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user