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
diff --git a/pom.xml b/pom.xml
index 8009271..1692689 100755
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
io.zeko
zeko-sql-builder
- 1.1.7-SNAPSHOT
+ 1.1.8-SNAPSHOT
jar
${project.groupId}:${project.artifactId}
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..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,102 +107,141 @@ 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 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)
}
-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.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)
+}
+
+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: Int): 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: Long): 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.neq(value: Double): QueryBlock {
+infix fun QueryBlock.neq(value: Any): 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)
}
+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)
@@ -224,14 +271,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 {
@@ -288,6 +335,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("", "")
}
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 "?")
}
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")