From 0cbaf8476adf307eea9a942376d1f7262d02d682 Mon Sep 17 00:00:00 2001 From: Leng Sheng Hong Date: Thu, 7 May 2020 03:02:03 +0800 Subject: [PATCH 1/7] add conditions to convert date time from Apache Ignite timestamp with millis (2020-05-06 17:15:03.322Z) to ZonedDateTime --- src/main/kotlin/io/zeko/model/Entity.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/io/zeko/model/Entity.kt b/src/main/kotlin/io/zeko/model/Entity.kt index a1b5f98..1407942 100644 --- a/src/main/kotlin/io/zeko/model/Entity.kt +++ b/src/main/kotlin/io/zeko/model/Entity.kt @@ -109,9 +109,17 @@ abstract class Entity { if (dateStr.indexOf("T") > 0) { pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX") } else { - pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SXXX") + // Apache ignite returns "2020-05-06 17:15:03.322Z" for timestamp columns + if (dateStr.length > 21 && dateStr[19] + "" == "." && dateStr[21] + "" != "Z") { + pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSXXX") + } else { + pattern = if (dateStr.indexOf(".") > 0) + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SXXX") + else + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssXXX") + } } - ZonedDateTime.parse(dateStr + "Z", pattern) + ZonedDateTime.parse(dateStr.removeSuffix("Z") + "Z", pattern) } else { //Vertx JDBC client returns date time field as String and already converted to UTC val pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ssXXX") From 4993b2e5f0c3967a3a605eb68ae25ec3c68f6d97 Mon Sep 17 00:00:00 2001 From: Leng Sheng Hong Date: Thu, 7 May 2020 21:16:12 +0800 Subject: [PATCH 2/7] accept Any for between --- src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt b/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt index dff5d36..22752b2 100644 --- a/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt +++ b/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt @@ -288,6 +288,9 @@ infix fun String.between(values: Pair<*, *>): QueryBlock { } else if (value1 is Double) { val value2 = values.second as Double return io.zeko.db.sql.operators.between(this, value1, value2) + } else { + val value2 = values.second + return io.zeko.db.sql.operators.between(this, value1.toString(), value2.toString()) } return QueryBlock("", "") } From e3c14746f8dc007b6d2f1a8231dbaec86543b12a Mon Sep 17 00:00:00 2001 From: Leng Sheng Hong Date: Thu, 7 May 2020 21:19:14 +0800 Subject: [PATCH 3/7] remove Redundant qualifier name --- .../kotlin/io/zeko/db/sql/dsl/declarations.kt | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt b/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt index 22752b2..98571af 100644 --- a/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt +++ b/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt @@ -99,99 +99,99 @@ infix fun String.lessEq(value: Double): QueryBlock { return io.zeko.db.sql.operators.lessEq(this, value) } -infix fun io.zeko.db.sql.QueryBlock.eq(value: String): QueryBlock { +infix fun QueryBlock.eq(value: String): QueryBlock { return io.zeko.db.sql.operators.eq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.eq(value: Int): QueryBlock { +infix fun QueryBlock.eq(value: Int): QueryBlock { return io.zeko.db.sql.operators.eq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.eq(value: Long): QueryBlock { +infix fun QueryBlock.eq(value: Long): QueryBlock { return io.zeko.db.sql.operators.eq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.eq(value: Double): QueryBlock { +infix fun QueryBlock.eq(value: Double): QueryBlock { return io.zeko.db.sql.operators.eq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.neq(value: String): QueryBlock { +infix fun QueryBlock.neq(value: String): QueryBlock { return io.zeko.db.sql.operators.neq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.neq(value: Int): QueryBlock { +infix fun QueryBlock.neq(value: Int): QueryBlock { return io.zeko.db.sql.operators.neq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.neq(value: Long): QueryBlock { +infix fun QueryBlock.neq(value: Long): QueryBlock { return io.zeko.db.sql.operators.neq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.neq(value: Double): QueryBlock { +infix fun QueryBlock.neq(value: Double): QueryBlock { return io.zeko.db.sql.operators.neq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.greater(value: String): QueryBlock { +infix fun QueryBlock.greater(value: String): QueryBlock { return io.zeko.db.sql.operators.greater(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.greaterEq(value: String): QueryBlock { +infix fun QueryBlock.greaterEq(value: String): QueryBlock { return io.zeko.db.sql.operators.greaterEq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.less(value: String): QueryBlock { +infix fun QueryBlock.less(value: String): QueryBlock { return io.zeko.db.sql.operators.less(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.lessEq(value: String): QueryBlock { +infix fun QueryBlock.lessEq(value: String): QueryBlock { return io.zeko.db.sql.operators.lessEq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.greater(value: Int): QueryBlock { +infix fun QueryBlock.greater(value: Int): QueryBlock { return io.zeko.db.sql.operators.greater(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.greaterEq(value: Int): QueryBlock { +infix fun QueryBlock.greaterEq(value: Int): QueryBlock { return io.zeko.db.sql.operators.greaterEq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.less(value: Int): QueryBlock { +infix fun QueryBlock.less(value: Int): QueryBlock { return io.zeko.db.sql.operators.less(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.lessEq(value: Int): QueryBlock { +infix fun QueryBlock.lessEq(value: Int): QueryBlock { return io.zeko.db.sql.operators.lessEq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.greater(value: Long): QueryBlock { +infix fun QueryBlock.greater(value: Long): QueryBlock { return io.zeko.db.sql.operators.greater(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.greaterEq(value: Long): QueryBlock { +infix fun QueryBlock.greaterEq(value: Long): QueryBlock { return io.zeko.db.sql.operators.greaterEq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.less(value: Long): QueryBlock { +infix fun QueryBlock.less(value: Long): QueryBlock { return io.zeko.db.sql.operators.less(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.lessEq(value: Long): QueryBlock { +infix fun QueryBlock.lessEq(value: Long): QueryBlock { return io.zeko.db.sql.operators.lessEq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.greater(value: Double): QueryBlock { +infix fun QueryBlock.greater(value: Double): QueryBlock { return io.zeko.db.sql.operators.greater(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.greaterEq(value: Double): QueryBlock { +infix fun QueryBlock.greaterEq(value: Double): QueryBlock { return io.zeko.db.sql.operators.greaterEq(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.less(value: Double): QueryBlock { +infix fun QueryBlock.less(value: Double): QueryBlock { return io.zeko.db.sql.operators.less(this.toString(), value) } -infix fun io.zeko.db.sql.QueryBlock.lessEq(value: Double): QueryBlock { +infix fun QueryBlock.lessEq(value: Double): QueryBlock { return io.zeko.db.sql.operators.lessEq(this.toString(), value) } @@ -224,14 +224,14 @@ infix fun String.isNotNull(value: Boolean): QueryBlock { if (value) { return io.zeko.db.sql.operators.isNotNull(this) } - return io.zeko.db.sql.QueryBlock("", "") + return QueryBlock("", "") } infix fun String.isNull(value: Boolean): QueryBlock { if (value) { return io.zeko.db.sql.operators.isNull(this) } - return io.zeko.db.sql.QueryBlock("", "") + return QueryBlock("", "") } infix fun String.inList(values: String): QueryBlock { From c7934467469a8f4c98a9ef5f704b14a0df43f508 Mon Sep 17 00:00:00 2001 From: Leng Sheng Hong Date: Thu, 7 May 2020 22:04:31 +0800 Subject: [PATCH 4/7] add to accept Any type for eq, neq, less, greater, lessEq and greaterEq --- .../kotlin/io/zeko/db/sql/dsl/declarations.kt | 47 +++++++++++++++++++ .../io/zeko/db/sql/operators/declarations.kt | 21 +++++++++ 2 files changed, 68 insertions(+) diff --git a/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt b/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt index 98571af..5dd89ec 100644 --- a/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt +++ b/src/main/kotlin/io/zeko/db/sql/dsl/declarations.kt @@ -19,6 +19,10 @@ infix fun String.eq(value: Double): QueryBlock { return io.zeko.db.sql.operators.eq(this, value) } +infix fun String.eq(value: Any): QueryBlock { + return io.zeko.db.sql.operators.eq(this, value) +} + infix fun String.neq(value: String): QueryBlock { return io.zeko.db.sql.operators.neq(this, value) } @@ -35,6 +39,10 @@ infix fun String.neq(value: Double): QueryBlock { return io.zeko.db.sql.operators.neq(this, value) } +infix fun String.neq(value: Any): QueryBlock { + return io.zeko.db.sql.operators.neq(this, value) +} + infix fun String.greater(value: String): QueryBlock { return io.zeko.db.sql.operators.greater(this, value) } @@ -99,6 +107,22 @@ infix fun String.lessEq(value: Double): QueryBlock { return io.zeko.db.sql.operators.lessEq(this, value) } +infix fun String.greater(value: Any): QueryBlock { + return io.zeko.db.sql.operators.greater(this, value) +} + +infix fun String.greaterEq(value: Any): QueryBlock { + return io.zeko.db.sql.operators.greaterEq(this, value) +} + +infix fun String.less(value: Any): QueryBlock { + return io.zeko.db.sql.operators.less(this, value) +} + +infix fun String.lessEq(value: Any): QueryBlock { + return io.zeko.db.sql.operators.lessEq(this, value) +} + infix fun QueryBlock.eq(value: String): QueryBlock { return io.zeko.db.sql.operators.eq(this.toString(), value) } @@ -115,6 +139,10 @@ infix fun QueryBlock.eq(value: Double): QueryBlock { return io.zeko.db.sql.operators.eq(this.toString(), value) } +infix fun QueryBlock.eq(value: Any): QueryBlock { + return io.zeko.db.sql.operators.eq(this.toString(), value) +} + infix fun QueryBlock.neq(value: String): QueryBlock { return io.zeko.db.sql.operators.neq(this.toString(), value) } @@ -131,6 +159,10 @@ infix fun QueryBlock.neq(value: Double): QueryBlock { return io.zeko.db.sql.operators.neq(this.toString(), value) } +infix fun QueryBlock.neq(value: Any): QueryBlock { + return io.zeko.db.sql.operators.neq(this.toString(), value) +} + infix fun QueryBlock.greater(value: String): QueryBlock { return io.zeko.db.sql.operators.greater(this.toString(), value) } @@ -195,6 +227,21 @@ infix fun QueryBlock.lessEq(value: Double): QueryBlock { return io.zeko.db.sql.operators.lessEq(this.toString(), value) } +infix fun QueryBlock.greater(value: Any): QueryBlock { + return io.zeko.db.sql.operators.greater(this.toString(), value) +} + +infix fun QueryBlock.greaterEq(value: Any): QueryBlock { + return io.zeko.db.sql.operators.greaterEq(this.toString(), value) +} + +infix fun QueryBlock.less(value: Any): QueryBlock { + return io.zeko.db.sql.operators.less(this.toString(), value) +} + +infix fun QueryBlock.lessEq(value: Any): QueryBlock { + return io.zeko.db.sql.operators.lessEq(this.toString(), value) +} infix fun String.like(value: String): QueryBlock { return io.zeko.db.sql.operators.like(this, value) diff --git a/src/main/kotlin/io/zeko/db/sql/operators/declarations.kt b/src/main/kotlin/io/zeko/db/sql/operators/declarations.kt index fc00cfa..2387936 100644 --- a/src/main/kotlin/io/zeko/db/sql/operators/declarations.kt +++ b/src/main/kotlin/io/zeko/db/sql/operators/declarations.kt @@ -35,6 +35,14 @@ fun neq(field: String, value: Long): QueryBlock { return QueryBlock(field, "!=", value.toString()) } +fun eq(field: String, value: Any): QueryBlock { + return QueryBlock(field, "=", "?") +} + +fun neq(field: String, value: Any): QueryBlock { + return QueryBlock(field, "!=", "?") +} + fun greater(field: String, field2: String): QueryBlock { return QueryBlock(field, ">", field2) } @@ -87,6 +95,19 @@ fun lessEq(field: String, value: Double): QueryBlock { return QueryBlock(field, "<=", value.toString()) } +fun greater(field: String, value: Any): QueryBlock { + return QueryBlock(field, ">", "?") +} +fun greaterEq(field: String, value: Any): QueryBlock { + return QueryBlock(field, ">=", "?") +} +fun less(field: String, value: Any): QueryBlock { + return QueryBlock(field, "<", "?") +} +fun lessEq(field: String, value: Any): QueryBlock { + return QueryBlock(field, "<=", "?") +} + fun like(field: String, value: String, useRawValue: Boolean = false): QueryBlock { return QueryBlock(field, "LIKE", if (useRawValue) "'${value.replace("'", "''")}'" else "?") } From 9c6decf38af97139a083bdbe7cff65ec516d0e70 Mon Sep 17 00:00:00 2001 From: Leng Sheng Hong Date: Thu, 7 May 2020 22:09:41 +0800 Subject: [PATCH 5/7] [maven-release-plugin] prepare release 1.1.7 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 8009271..03f1579 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.zeko zeko-sql-builder - 1.1.7-SNAPSHOT + 1.1.7 jar ${project.groupId}:${project.artifactId} @@ -40,7 +40,7 @@ scm:git:https://github.com/darkredz/Zeko-SQL-Builder.git scm:git:ssh://github.com/darkredz/Zeko-SQL-Builder.git https://github.com/darkredz/Zeko-SQL-Builder - HEAD + 1.1.7 From b22a20f70b3c693da4b4bb4d7b54190acadf9c46 Mon Sep 17 00:00:00 2001 From: Leng Sheng Hong Date: Thu, 7 May 2020 22:09:41 +0800 Subject: [PATCH 6/7] [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 03f1579..1692689 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.zeko zeko-sql-builder - 1.1.7 + 1.1.8-SNAPSHOT jar ${project.groupId}:${project.artifactId} @@ -40,7 +40,7 @@ scm:git:https://github.com/darkredz/Zeko-SQL-Builder.git scm:git:ssh://github.com/darkredz/Zeko-SQL-Builder.git https://github.com/darkredz/Zeko-SQL-Builder - 1.1.7 + HEAD From c1f490c0add052fe24ca2a973f48f61002b680b2 Mon Sep 17 00:00:00 2001 From: Leng Sheng Hong Date: Thu, 7 May 2020 22:18:26 +0800 Subject: [PATCH 7/7] update version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 067ae92..8fde9c6 100644 --- a/README.md +++ b/README.md @@ -752,7 +752,7 @@ Add this to your maven pom.xml io.zeko zeko-sql-builder - 1.1.6 + 1.1.7