Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running into issues with missing parameters #46

Open
dfontenot opened this issue Jun 3, 2022 · 0 comments
Open

Running into issues with missing parameters #46

dfontenot opened this issue Jun 3, 2022 · 0 comments

Comments

@dfontenot
Copy link

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 Instants):

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant