Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

prepared statement not working when in operator in statement with conjunction with Seq[String] #228

Open
shachr opened this issue Aug 1, 2017 · 2 comments

Comments

@shachr
Copy link

shachr commented Aug 1, 2017

prepared statement not working when in operator in statement with conjunction with Seq[String],

code:

def getDemand(advertizerId: String, demandIds: Seq[String]): Future[Array[QueryResult]] = {
    val args = List(advertizerId, value)
    val query: String = s"""SELECT "demand_id"
                      |from demand where "partner_id"=? and "demand_id" in (?);""".stripMargin
    connection.sendPreparedStatement(query, args)
}

demand_id is a string field (character varying(32))

pg sql logs:

2017-08-01 16:23:35 IDT LOG:  execute 1/1: SELECT "demand_id" from demand where "partner_id"=$1 and "demand_id" in ($2);
2017-08-01 16:23:35 IDT DETAIL:  parameters: $1 = 'ea47ef7e8b4c4847894004198e7b9e56', $2 = '{"565f776a61db4ccdab36946116699622"}'

I couldn't figure out what todo, i tried to serialize to comma separated list myself but this didn't work as well, directly on the db its working obviously.

thanks.

@shachr shachr changed the title prepared statement not working for in operation prepared statement not working when in operator in statement with conjunction with Seq[String] Aug 1, 2017
@liorhar
Copy link

liorhar commented Oct 21, 2017

bumped into the same problem, SELECT * FROM bar WHERE column IN (?) with a parameter in the form of list/seq doesn't work. any workaround?

@liorhar
Copy link

liorhar commented Oct 24, 2017

found a workaround (at least for postgre) one can write SELECT * from bar WHERE column = ANY(?) then pass an array or list. It should have the same results (see here)

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

No branches or pull requests

2 participants