diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 4b84c6c..5723286 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -18,6 +18,8 @@
jdbc:postgresql://127.0.0.1:${pg.port}/${pg.dbname}
${project.build.directory}/generated-sources/jooq
+
+ 1.4.21
@@ -37,6 +39,12 @@
test
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ true
+
+
junit
junit
@@ -188,6 +196,29 @@
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+ ${kotlin.version}
+
+ 1.8
+
+
+
+ test-compile
+
+ test-compile
+
+
+
+ ${project.basedir}/src/test/kotlin
+
+
+
+
+
+
+
org.codehaus.mojo
build-helper-maven-plugin
diff --git a/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/JsonKotlinIT.kt b/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/JsonKotlinIT.kt
new file mode 100644
index 0000000..697c7cf
--- /dev/null
+++ b/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/JsonKotlinIT.kt
@@ -0,0 +1,85 @@
+package com.github.t9t.jooq.json
+
+import com.github.t9t.jooq.generated.Tables
+import org.jooq.JSON
+import org.jooq.JSONB
+import org.jooq.Record1
+import org.jooq.SQLDialect
+import org.jooq.impl.DSL
+import org.junit.Assert
+import org.junit.Assert.assertEquals
+import org.junit.Before
+import org.junit.Test
+
+/**
+ * Validates Kotlin, jOOQ and JSON(B) interoperability
+ */
+class JsonKotlinIT {
+ private val ds = TestDb.createDataSource()
+ private val dsl = DSL.using(ds, SQLDialect.POSTGRES)
+
+ @Before
+ fun setUp() {
+ dsl.deleteFrom(Tables.JSON_TEST).execute()
+ assertEquals(4, dsl.execute("insert into jooq.json_test (name, data, datab)" +
+ " values " +
+ "('both', '{\"json\": {\"int\": 100, \"str\": \"Hello, JSON world!\", \"object\": {\"v\": 200}, \"n\": null}}', '{\"jsonb\": {\"int\": 100, \"str\": \"Hello, JSONB world!\", \"object\": {\"v\": 200}, \"n\": null}}')," +
+ "('empty', '{}', '{}')," +
+ "('null-sql', null, null)," +
+ "('null-json', 'null'::json, 'null'::jsonb)").toLong())
+ }
+
+ @Test
+ fun `select JSON NULL SQL, returning non-null JSON type`() {
+ val r: Record1 = dsl.select(Tables.JSON_TEST.DATA)
+ .from(Tables.JSON_TEST)
+ .where(Tables.JSON_TEST.NAME.eq("null-sql"))
+ .fetchOne()!!
+ Assert.assertNull(r.value1())
+ }
+
+ @Test
+ fun `select JSON NULL SQL, returning nullable JSON type`() {
+ val r: Record1 = dsl.select(Tables.JSON_TEST.DATA)
+ .from(Tables.JSON_TEST)
+ .where(Tables.JSON_TEST.NAME.eq("null-sql"))
+ .fetchOne()!!
+ Assert.assertNull(r.value1())
+ }
+
+ @Test
+ fun `select null JSON value`() {
+ val r: Record1 = dsl.select(Tables.JSON_TEST.DATA)
+ .from(Tables.JSON_TEST)
+ .where(Tables.JSON_TEST.NAME.eq("null-json"))
+ .fetchOne()!!
+ assertEquals("null", r.value1().toString())
+ }
+
+ @Test
+ fun `select JSON NULL SQL, returning non-null JSONB type`() {
+ val r: Record1 = dsl.select(Tables.JSON_TEST.DATAB)
+ .from(Tables.JSON_TEST)
+ .where(Tables.JSON_TEST.NAME.eq("null-sql"))
+ .fetchOne()!!
+ Assert.assertNull(r.value1())
+ }
+
+ @Test
+ fun `select JSON NULL SQL, returning nullable JSONB type`() {
+ val r: Record1 = dsl.select(Tables.JSON_TEST.DATAB)
+ .from(Tables.JSON_TEST)
+ .where(Tables.JSON_TEST.NAME.eq("null-sql"))
+ .fetchOne()!!
+ Assert.assertNull(r.value1())
+ }
+
+ @Test
+ fun `select null JSONB value`() {
+ val r = dsl.select(Tables.JSON_TEST.DATAB)
+ .from(Tables.JSON_TEST)
+ .where(Tables.JSON_TEST.NAME.eq("null-json"))
+ .fetchOne()!!
+ assertEquals("null", r.value1().toString())
+ }
+}
diff --git a/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/json/JsonDSLTest.kt b/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/json/JsonDSLTest.kt
new file mode 100644
index 0000000..145f4c7
--- /dev/null
+++ b/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/json/JsonDSLTest.kt
@@ -0,0 +1,187 @@
+package com.github.t9t.jooq.json.json
+
+import com.github.t9t.jooq.json.JsonDSL
+import org.jooq.Field
+import org.jooq.JSON
+import org.jooq.impl.DSL
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class JsonDSLTest {
+
+ private val jsonField: Field = DSL.field("foo.bar", JSON::class.java)
+
+ @Test
+ fun `should provide extension function to create field from JSON`() {
+ /* Given */
+ val json = JSON.valueOf("{}")
+ /* When */
+ val jsonField = JsonDSL.field(json)
+ val jsonFieldExt = json.toField()
+ /* Then */
+ assertEquals(jsonField, jsonFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for arrayElement`() {
+ /* Given */
+ val index = 1
+ /* When */
+ val arrayElementField = JsonDSL.arrayElement(jsonField, index)
+ val arrayElementFieldExt = jsonField.arrayElement(index)
+ /* Then */
+ assertEquals(arrayElementField, arrayElementFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for arrayElementText`() {
+ /* Given */
+ val index = 1
+ /* When */
+ val arrayElementTextField = JsonDSL.arrayElementText(jsonField, index)
+ val arrayElementTextFieldExt = jsonField.arrayElementText(index)
+ /* Then */
+ assertEquals(arrayElementTextField, arrayElementTextFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for fieldByKey`() {
+ /* Given */
+ val key = "key"
+ /* When */
+ val fieldByKeyField = JsonDSL.fieldByKey(jsonField, key)
+ val fieldByKeyFieldExt = jsonField.fieldByKey(key)
+ /* Then */
+ assertEquals(fieldByKeyField, fieldByKeyFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for fieldByKeyText`() {
+ /* Given */
+ val key = "key"
+ /* When */
+ val fieldByKeyTextField = JsonDSL.fieldByKeyText(jsonField, key)
+ val fieldByKeyTextFieldExt = jsonField.fieldByKeyText(key)
+ /* Then */
+ assertEquals(fieldByKeyTextField, fieldByKeyTextFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for objectAtPath with varargs`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val objectAtPathField = JsonDSL.objectAtPath(jsonField, *path)
+ val objectAtPathFieldExt = jsonField.objectAtPath(*path)
+ /* Then */
+ assertEquals(objectAtPathField, objectAtPathFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for objectAtPath with collection`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val objectAtPathField = JsonDSL.objectAtPath(jsonField, path.toList())
+ val objectAtPathFieldExt = jsonField.objectAtPath(path.toList())
+ /* Then */
+ assertEquals(objectAtPathField, objectAtPathFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for objectAtPathText with varargs`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val objectAtPathTextField = JsonDSL.objectAtPathText(jsonField, *path)
+ val objectAtPathTextFieldExt = jsonField.objectAtPathText(*path)
+ /* Then */
+ assertEquals(objectAtPathTextField, objectAtPathTextFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for objectAtPathText with collection`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val objectAtPathTextField = JsonDSL.objectAtPathText(jsonField, path.toList())
+ val objectAtPathTextFieldExt = jsonField.objectAtPathText(path.toList())
+ /* Then */
+ assertEquals(objectAtPathTextField, objectAtPathTextFieldExt)
+ }
+
+ @Test
+ fun `should provide function for arrayLength`() {
+ /* Given */
+ /* When */
+ val arrayLengthField = JsonDSL.arrayLength(jsonField)
+ val arrayLengthFieldExt = arrayLength(jsonField)
+ /* Then */
+ assertEquals(arrayLengthField, arrayLengthFieldExt)
+ }
+
+ @Test
+ fun `should provide function for extractPath with varargs`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val extractPathField = JsonDSL.extractPath(jsonField, *path)
+ val extractPathFieldExt = extractPath(jsonField, *path)
+ /* Then */
+ assertEquals(extractPathField, extractPathFieldExt)
+ }
+
+ @Test
+ fun `should provide function for extractPath with collection`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val extractPathField = JsonDSL.extractPath(jsonField, path.toList())
+ val extractPathFieldExt = extractPath(jsonField, path.toList())
+ /* Then */
+ assertEquals(extractPathField, extractPathFieldExt)
+ }
+
+ @Test
+ fun `should provide function for extractPathText with varargs`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val extractPathTextField = JsonDSL.extractPathText(jsonField, *path)
+ val extractPathTextFieldExt = extractPathText(jsonField, *path)
+ /* Then */
+ assertEquals(extractPathTextField, extractPathTextFieldExt)
+ }
+
+ @Test
+ fun `should provide function for extractPathText with collection`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val extractPathTextField = JsonDSL.extractPathText(jsonField, path.toList())
+ val extractPathTextFieldExt = extractPathText(jsonField, path.toList())
+ /* Then */
+ assertEquals(extractPathTextField, extractPathTextFieldExt)
+ }
+
+ @Test
+ fun `should provide function for typeOf`() {
+ /* Given */
+ /* When */
+ val typeOfField = JsonDSL.typeOf(jsonField)
+ val typeOfFieldExt = typeOf(jsonField)
+ /* Then */
+ assertEquals(typeOfField, typeOfFieldExt)
+ }
+
+ @Test
+ fun `should provide function for stripNulls`() {
+ /* Given */
+ /* When */
+ val stripNullsField = JsonDSL.stripNulls(jsonField)
+ val stripNullsFieldExt = stripNulls(jsonField)
+ /* Then */
+ assertEquals(stripNullsField, stripNullsFieldExt)
+ }
+
+}
diff --git a/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/jsonb/JsonbDSLTest.kt b/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/jsonb/JsonbDSLTest.kt
new file mode 100644
index 0000000..49ec627
--- /dev/null
+++ b/integration-tests/src/test/kotlin/com/github/t9t/jooq/json/jsonb/JsonbDSLTest.kt
@@ -0,0 +1,333 @@
+package com.github.t9t.jooq.json.jsonb
+
+import com.github.t9t.jooq.json.JsonbDSL
+import org.jooq.Field
+import org.jooq.JSONB
+import org.jooq.impl.DSL
+import org.junit.Assert.assertEquals
+import org.junit.Test
+
+class JsonbDSLTest {
+
+ private val jsonbField: Field = DSL.field("foo.bar", JSONB::class.java)
+
+ @Test
+ fun `should provide extension function to create field from JSON`() {
+ /* Given */
+ val jsonb = JSONB.valueOf("{}")
+ /* When */
+ val jsonbField = JsonbDSL.field(jsonb)
+ val jsonbFieldExt = jsonb.toField()
+ /* Then */
+ assertEquals(jsonbField, jsonbFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for arrayElement`() {
+ /* Given */
+ val index = 1
+ /* When */
+ val arrayElementField = JsonbDSL.arrayElement(jsonbField, index)
+ val arrayElementFieldExt = jsonbField.arrayElement(index)
+ /* Then */
+ assertEquals(arrayElementField, arrayElementFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for arrayElementText`() {
+ /* Given */
+ val index = 1
+ /* When */
+ val arrayElementTextField = JsonbDSL.arrayElementText(jsonbField, index)
+ val arrayElementTextFieldExt = jsonbField.arrayElementText(index)
+ /* Then */
+ assertEquals(arrayElementTextField, arrayElementTextFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for fieldByKey`() {
+ /* Given */
+ val key = "key"
+ /* When */
+ val fieldByKeyField = JsonbDSL.fieldByKey(jsonbField, key)
+ val fieldByKeyFieldExt = jsonbField.fieldByKey(key)
+ /* Then */
+ assertEquals(fieldByKeyField, fieldByKeyFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for fieldByKeyText`() {
+ /* Given */
+ val key = "key"
+ /* When */
+ val fieldByKeyTextField = JsonbDSL.fieldByKeyText(jsonbField, key)
+ val fieldByKeyTextFieldExt = jsonbField.fieldByKeyText(key)
+ /* Then */
+ assertEquals(fieldByKeyTextField, fieldByKeyTextFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for objectAtPath with varargs`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val objectAtPathField = JsonbDSL.objectAtPath(jsonbField, *path)
+ val objectAtPathFieldExt = jsonbField.objectAtPath(*path)
+ /* Then */
+ assertEquals(objectAtPathField, objectAtPathFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for objectAtPath with collection`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val objectAtPathField = JsonbDSL.objectAtPath(jsonbField, path.toList())
+ val objectAtPathFieldExt = jsonbField.objectAtPath(path.toList())
+ /* Then */
+ assertEquals(objectAtPathField, objectAtPathFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for objectAtPathText with varargs`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val objectAtPathTextField = JsonbDSL.objectAtPathText(jsonbField, *path)
+ val objectAtPathTextFieldExt = jsonbField.objectAtPathText(*path)
+ /* Then */
+ assertEquals(objectAtPathTextField, objectAtPathTextFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for objectAtPathText with collection`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val objectAtPathTextField = JsonbDSL.objectAtPathText(jsonbField, path.toList())
+ val objectAtPathTextFieldExt = jsonbField.objectAtPathText(path.toList())
+ /* Then */
+ assertEquals(objectAtPathTextField, objectAtPathTextFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for contains`() {
+ /* Given */
+ val other: Field = DSL.field("other.bar", JSONB::class.java)
+ /* When */
+ val containsField = JsonbDSL.contains(jsonbField, other)
+ val containsFieldExt = jsonbField.containsJson(other)
+ /* Then */
+ assertEquals(containsField, containsFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for containedIn`() {
+ /* Given */
+ val other: Field = DSL.field("other.bar", JSONB::class.java)
+ /* When */
+ val containedInField = JsonbDSL.containedIn(jsonbField, other)
+ val containedInFieldExt = jsonbField.containedIn(other)
+ /* Then */
+ assertEquals(containedInField, containedInFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for hasKey`() {
+ /* Given */
+ val key = "bar"
+ /* When */
+ val hasKeyField = JsonbDSL.hasKey(jsonbField, key)
+ val hasKeyFieldExt = jsonbField.hasKey(key)
+ /* Then */
+ assertEquals(hasKeyField, hasKeyFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for hasAnyKey with varargs`() {
+ /* Given */
+ val keys = arrayOf("key1", "key2")
+ /* When */
+ val hasAnyKeyField = JsonbDSL.hasAnyKey(jsonbField, *keys)
+ val hasAnyKeyFieldExt = jsonbField.hasAnyKey(*keys)
+ /* Then */
+ assertEquals(hasAnyKeyField, hasAnyKeyFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for hasAnyKey with Collection`() {
+ /* Given */
+ val keys = arrayOf("key1", "key2")
+ /* When */
+ val hasAnyKeyField = JsonbDSL.hasAnyKey(jsonbField, keys.toList())
+ val hasAnyKeyFieldExt = jsonbField.hasAnyKey(keys.toList())
+ /* Then */
+ assertEquals(hasAnyKeyField, hasAnyKeyFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for hasAllKeys with varargs`() {
+ /* Given */
+ val keys = arrayOf("key1", "key2")
+ /* When */
+ val hasAllKeysField = JsonbDSL.hasAllKeys(jsonbField, *keys)
+ val hasAllKeysFieldExt = jsonbField.hasAllKeys(*keys)
+ /* Then */
+ assertEquals(hasAllKeysField, hasAllKeysFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for hasAllKeys with Collection`() {
+ /* Given */
+ val keys = arrayOf("key1", "key2")
+ /* When */
+ val hasAllKeysField = JsonbDSL.hasAllKeys(jsonbField, keys.toList())
+ val hasAllKeysFieldExt = jsonbField.hasAllKeys(keys.toList())
+ /* Then */
+ assertEquals(hasAllKeysField, hasAllKeysFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for concat`() {
+ /* Given */
+ val other: Field = DSL.field("other.bar", JSONB::class.java)
+ /* When */
+ val concatField = JsonbDSL.concat(jsonbField, other)
+ val concatFieldExt = jsonbField.concatJson(other)
+ /* Then */
+ assertEquals(concatField, concatFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for delete with key or element`() {
+ /* Given */
+ val key = "foo"
+ /* When */
+ val deleteField = JsonbDSL.delete(jsonbField, key)
+ val deleteFieldExt = jsonbField.delete(key)
+ /* Then */
+ assertEquals(deleteField, deleteFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for delete with varargs`() {
+ /* Given */
+ val keys = arrayOf("key1", "key2")
+ /* When */
+ val deleteField = JsonbDSL.delete(jsonbField, *keys)
+ val deleteFieldExt = jsonbField.delete(*keys)
+ /* Then */
+ assertEquals(deleteField, deleteFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for deleteElement`() {
+ /* Given */
+ val index = 1
+ /* When */
+ val deleteElementField = JsonbDSL.deleteElement(jsonbField, index)
+ val deleteElementFieldExt = jsonbField.deleteElement(index)
+ /* Then */
+ assertEquals(deleteElementField, deleteElementFieldExt)
+ }
+
+ @Test
+ fun `should provide extension function for deletePath`() {
+ /* Given */
+ val keys = arrayOf("key1", "key2")
+ /* When */
+ val deletePathField = JsonbDSL.deletePath(jsonbField, *keys)
+ val deletePathFieldExt = jsonbField.deletePath(*keys)
+ /* Then */
+ assertEquals(deletePathField, deletePathFieldExt)
+ }
+
+
+
+
+
+ @Test
+ fun `should provide function for arrayLength`() {
+ /* Given */
+ /* When */
+ val arrayLengthField = JsonbDSL.arrayLength(jsonbField)
+ val arrayLengthFieldExt = arrayLength(jsonbField)
+ /* Then */
+ assertEquals(arrayLengthField, arrayLengthFieldExt)
+ }
+
+ @Test
+ fun `should provide function for extractPath with varargs`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val extractPathField = JsonbDSL.extractPath(jsonbField, *path)
+ val extractPathFieldExt = extractPath(jsonbField, *path)
+ /* Then */
+ assertEquals(extractPathField, extractPathFieldExt)
+ }
+
+ @Test
+ fun `should provide function for extractPath with collection`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val extractPathField = JsonbDSL.extractPath(jsonbField, path.toList())
+ val extractPathFieldExt = extractPath(jsonbField, path.toList())
+ /* Then */
+ assertEquals(extractPathField, extractPathFieldExt)
+ }
+
+ @Test
+ fun `should provide function for extractPathText with varargs`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val extractPathTextField = JsonbDSL.extractPathText(jsonbField, *path)
+ val extractPathTextFieldExt = extractPathText(jsonbField, *path)
+ /* Then */
+ assertEquals(extractPathTextField, extractPathTextFieldExt)
+ }
+
+ @Test
+ fun `should provide function for extractPathText with collection`() {
+ /* Given */
+ val path = arrayOf("path", "to", "key")
+ /* When */
+ val extractPathTextField = JsonbDSL.extractPathText(jsonbField, path.toList())
+ val extractPathTextFieldExt = extractPathText(jsonbField, path.toList())
+ /* Then */
+ assertEquals(extractPathTextField, extractPathTextFieldExt)
+ }
+
+ @Test
+ fun `should provide function for typeOf`() {
+ /* Given */
+ /* When */
+ val typeOfField = JsonbDSL.typeOf(jsonbField)
+ val typeOfFieldExt = typeOf(jsonbField)
+ /* Then */
+ assertEquals(typeOfField, typeOfFieldExt)
+ }
+
+ @Test
+ fun `should provide function for stripNulls`() {
+ /* Given */
+ /* When */
+ val stripNullsField = JsonbDSL.stripNulls(jsonbField)
+ val stripNullsFieldExt = stripNulls(jsonbField)
+ /* Then */
+ assertEquals(stripNullsField, stripNullsFieldExt)
+ }
+
+ @Test
+ fun `should provide function for pretty`() {
+ /* Given */
+ /* When */
+ val prettyField = JsonbDSL.pretty(jsonbField)
+ val prettyFieldExt = pretty(jsonbField)
+ /* Then */
+ assertEquals(prettyField, prettyFieldExt)
+ }
+
+}
diff --git a/jooq-postgresql-json/pom.xml b/jooq-postgresql-json/pom.xml
index fd8b95c..2546121 100644
--- a/jooq-postgresql-json/pom.xml
+++ b/jooq-postgresql-json/pom.xml
@@ -17,6 +17,13 @@
org.jooq
jooq
+
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ true
+
+
@@ -26,6 +33,41 @@
maven-jar-plugin
+
+ org.jetbrains.kotlin
+ kotlin-maven-plugin
+ ${kotlin.version}
+
+ 1.8
+
+
+
+ compile
+
+ compile
+
+
+
+ ${project.basedir}/src/main/kotlin
+ ${project.basedir}/src/main/java
+
+
+
+
+ test-compile
+
+ test-compile
+
+
+
+ ${project.basedir}/src/test/kotlin
+ ${project.basedir}/src/test/java
+
+
+
+
+
+
org.apache.maven.plugins
maven-source-plugin
diff --git a/jooq-postgresql-json/src/main/kotlin/com/github/t9t/jooq/json/json/JsonDSL.kt b/jooq-postgresql-json/src/main/kotlin/com/github/t9t/jooq/json/json/JsonDSL.kt
new file mode 100644
index 0000000..3bb82b1
--- /dev/null
+++ b/jooq-postgresql-json/src/main/kotlin/com/github/t9t/jooq/json/json/JsonDSL.kt
@@ -0,0 +1,86 @@
+package com.github.t9t.jooq.json.json
+
+import com.github.t9t.jooq.json.JsonDSL
+import org.jooq.Field
+import org.jooq.JSON
+
+
+/**
+ * @see JsonDSL.field
+ */
+fun JSON.toField(): Field = JsonDSL.field(this)
+
+/**
+ * @see JsonDSL.arrayElement
+ */
+fun Field.arrayElement(index: Int): Field = JsonDSL.arrayElement(this, index)
+
+/**
+ * @see JsonDSL.arrayElementText
+ */
+fun Field.arrayElementText(index: Int): Field = JsonDSL.arrayElementText(this, index)
+
+/**
+ * @see JsonDSL.fieldByKey
+ */
+fun Field.fieldByKey(key: String): Field = JsonDSL.fieldByKey(this, key)
+
+/**
+ * @see JsonDSL.fieldByKeyText
+ */
+fun Field.fieldByKeyText(key: String): Field = JsonDSL.fieldByKeyText(this, key)
+
+/**
+ * @see JsonDSL.objectAtPath
+ */
+fun Field.objectAtPath(vararg path: String): Field = JsonDSL.objectAtPath(this, *path)
+
+/**
+ * @see JsonDSL.objectAtPath
+ */
+fun Field.objectAtPath(path: Collection): Field = JsonDSL.objectAtPath(this, path)
+
+/**
+ * @see JsonDSL.objectAtPathText
+ */
+fun Field.objectAtPathText(vararg path: String): Field = JsonDSL.objectAtPathText(this, *path)
+
+/**
+ * @see JsonDSL.objectAtPathText
+ */
+fun Field.objectAtPathText(path: Collection): Field = JsonDSL.objectAtPathText(this, path)
+
+/**
+ * @see JsonDSL.arrayLength
+ */
+fun arrayLength(jsonField: Field): Field = JsonDSL.arrayLength(jsonField)
+
+/**
+ * @see JsonDSL.extractPath
+ */
+fun extractPath(jsonField: Field, vararg path: String): Field = JsonDSL.extractPath(jsonField, *path)
+
+/**
+ * @see JsonDSL.extractPath
+ */
+fun extractPath(jsonField: Field, path: Collection): Field = JsonDSL.extractPath(jsonField, path)
+
+/**
+ * @see JsonDSL.extractPathText
+ */
+fun extractPathText(jsonField: Field, vararg path: String): Field = JsonDSL.extractPathText(jsonField, *path)
+
+/**
+ * @see JsonDSL.extractPathText
+ */
+fun extractPathText(jsonField: Field, path: Collection): Field = JsonDSL.extractPathText(jsonField, path)
+
+/**
+ * @see JsonDSL.typeOf
+ */
+fun typeOf(jsonField: Field): Field = JsonDSL.typeOf(jsonField)
+
+/**
+ * @see JsonDSL.stripNulls
+ */
+fun stripNulls(jsonField: Field): Field = JsonDSL.stripNulls(jsonField)
diff --git a/jooq-postgresql-json/src/main/kotlin/com/github/t9t/jooq/json/jsonb/JsonbDSL.kt b/jooq-postgresql-json/src/main/kotlin/com/github/t9t/jooq/json/jsonb/JsonbDSL.kt
new file mode 100644
index 0000000..3b9d7c3
--- /dev/null
+++ b/jooq-postgresql-json/src/main/kotlin/com/github/t9t/jooq/json/jsonb/JsonbDSL.kt
@@ -0,0 +1,151 @@
+package com.github.t9t.jooq.json.jsonb
+
+import com.github.t9t.jooq.json.JsonbDSL
+import org.jooq.Condition
+import org.jooq.Field
+import org.jooq.JSONB
+
+/**
+ * @see JsonbDSL.field
+ */
+fun JSONB.toField(): Field = JsonbDSL.field(this)
+
+/**
+ * @see JsonbDSL.arrayElement
+ */
+fun Field.arrayElement(index: Int): Field = JsonbDSL.arrayElement(this, index)
+
+/**
+ * @see JsonbDSL.arrayElementText
+ */
+fun Field.arrayElementText(index: Int): Field = JsonbDSL.arrayElementText(this, index)
+
+/**
+ * @see JsonbDSL.fieldByKey
+ */
+fun Field.fieldByKey(key: String): Field = JsonbDSL.fieldByKey(this, key)
+
+/**
+ * @see JsonbDSL.fieldByKeyText
+ */
+fun Field.fieldByKeyText(key: String): Field = JsonbDSL.fieldByKeyText(this, key)
+
+/**
+ * @see JsonbDSL.objectAtPath
+ */
+fun Field.objectAtPath(vararg path: String): Field = JsonbDSL.objectAtPath(this, *path)
+
+/**
+ * @see JsonbDSL.objectAtPath
+ */
+fun Field.objectAtPath(path: Collection): Field = JsonbDSL.objectAtPath(this, path)
+
+/**
+ * @see JsonbDSL.objectAtPathText
+ */
+fun Field.objectAtPathText(vararg path: String): Field = JsonbDSL.objectAtPathText(this, *path)
+
+/**
+ * @see JsonbDSL.objectAtPathText
+ */
+fun Field.objectAtPathText(path: Collection): Field = JsonbDSL.objectAtPathText(this, path)
+
+/**
+ * @see JsonbDSL.contains
+ */
+fun Field.containsJson(other: Field): Condition = JsonbDSL.contains(this, other)
+
+/**
+ * @see JsonbDSL.containedIn
+ */
+fun Field.containedIn(other: Field): Condition = JsonbDSL.containedIn(this, other)
+
+/**
+ * @see JsonbDSL.hasKey
+ */
+fun Field.hasKey(key: String): Condition = JsonbDSL.hasKey(this, key)
+
+/**
+ * @see JsonbDSL.hasAnyKey
+ */
+fun Field.hasAnyKey(vararg keys: String): Condition = JsonbDSL.hasAnyKey(this, *keys)
+
+/**
+ * @see JsonbDSL.hasAnyKey
+ */
+fun Field.hasAnyKey(keys: Collection): Condition = JsonbDSL.hasAnyKey(this, keys)
+
+/**
+ * @see JsonbDSL.hasAllKeys
+ */
+fun Field.hasAllKeys(vararg keys: String): Condition = JsonbDSL.hasAllKeys(this, *keys)
+
+/**
+ * @see JsonbDSL.hasAllKeys
+ */
+fun Field.hasAllKeys(keys: Collection): Condition = JsonbDSL.hasAllKeys(this, keys)
+
+/**
+ * @see JsonbDSL.concat
+ */
+fun Field.concatJson(field2: Field): Field = JsonbDSL.concat(this, field2)
+
+/**
+ * @see JsonbDSL.delete
+ */
+fun Field.delete(keyOrElement: String): Field = JsonbDSL.delete(this, keyOrElement)
+
+/**
+ * @see JsonbDSL.delete
+ */
+fun Field.delete(vararg keysOrElements: String): Field = JsonbDSL.delete(this, *keysOrElements)
+
+/**
+ * @see JsonbDSL.deleteElement
+ */
+fun Field.deleteElement(index: Int): Field = JsonbDSL.deleteElement(this, index)
+
+/**
+ * @see JsonbDSL.deletePath
+ */
+fun Field.deletePath(vararg path: String): Field = JsonbDSL.deletePath(this, *path)
+
+/**
+ * @see JsonbDSL.arrayLength
+ */
+fun arrayLength(jsonField: Field): Field = JsonbDSL.arrayLength(jsonField)
+
+/**
+ * @see JsonbDSL.extractPath
+ */
+fun extractPath(jsonField: Field, vararg path: String): Field = JsonbDSL.extractPath(jsonField, *path)
+
+/**
+ * @see JsonbDSL.extractPath
+ */
+fun extractPath(jsonField: Field, path: Collection): Field = JsonbDSL.extractPath(jsonField, *path.toTypedArray())
+
+/**
+ * @see JsonbDSL.extractPathText
+ */
+fun extractPathText(jsonField: Field, vararg path: String): Field = JsonbDSL.extractPathText(jsonField, *path)
+
+/**
+ * @see JsonbDSL.extractPathText
+ */
+fun extractPathText(jsonField: Field, path: Collection): Field = JsonbDSL.extractPathText(jsonField, *path.toTypedArray())
+
+/**
+ * @see JsonbDSL.typeOf
+ */
+fun typeOf(jsonField: Field): Field = JsonbDSL.typeOf(jsonField)
+
+/**
+ * @see JsonbDSL.stripNulls
+ */
+fun stripNulls(jsonField: Field): Field = JsonbDSL.stripNulls(jsonField)
+
+/**
+ * @see JsonbDSL.pretty
+ */
+fun pretty(jsonField: Field): Field = JsonbDSL.pretty(jsonField)
diff --git a/pom.xml b/pom.xml
index 6ebad61..63ed566 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,6 +22,7 @@
3.14.4
42.2.18
7.3.1
+ 1.4.21
@@ -45,6 +46,12 @@
test
+
+ org.jetbrains.kotlin
+ kotlin-stdlib
+ ${kotlin.version}
+
+
junit
junit