Running into issues with missing parameters
Opened this issue · 0 comments
Hello,
I am working on a query and an insert using Zeko, and I'm having issues with the column number not matching the number of parameterized question marks in the query.
If these are not the same underlying issue, I can split them into different Github issues (assuming it's not a misunderstanding on my side).
Select query (selecting everything between two user-inputted Instant
s):
val query = Query()
.fields("*")
.from(TABLE)
.where(
("$TABLE.timestamp" greaterEq from) and
("$TABLE.timestamp" lessEq to)
)
val (sql, columns) = query.compile(true)
lateinit var rows: List<MyDTO>
dbSession.retry(2) { conn ->
println(sql)
println("the columns")
println(columns)
rows = conn.queryPrepared(sql, columns, { MyDTO(it) })
}
If I run the query, columns
is an empty array.
The insert (using the onDuplicateUpdate() functionality (thank you for adding that btw)):
val foo = MyOtherDTO().apply {
id = "some guid"
bar = "baz"
baz = "qux"
}
val insertStatement = Insert(transaction, true)
.onDuplicateUpdate(
mapOf("bar" to "corge",
)
)
lateinit var rows: List<MyOtherDTO>
dbSession.retry(2) { conn ->
println("the params")
println(insert.params())
rows = conn.insert(insert.toSql(), insert.params(), closeStatement=true, closeConn=false) as List<MyOtherDTO>
}
In this case, the params contain the contents of val foo
, but the query fails because it is has more question marks than what is provided.
Is there something that I'm doing wrong on my end; do I need to change how I'm specifying the queries and the inserts?