3

I have the query:

val sql = """select
                   id,
                   clientName
             from
                  partnerClients
             where
                  partnerName = ?
          """

I read partnerName from excel file and for each I perform the func:

case class Partner(name: String)
case class Client(id: Int, name: String)

def queryPartnerClients(partnerName: String) = Query[String, Client](sql, None).toQuery0(partnerName)

def getPartnerClients(partner: Partner): IO[Vector[Client]] =  partnerClients(partner.name)                                             
                                                              .to[Vector]
                                                              .transact(xa)

I used this FAQ (How do I turn an arbitrary SQL string into a Query/Query0)

The problem is getting empty results when I take partner name from excel, but it works if I specify the same partner name in the code like this for example:

def partnerClients(partnerName: String) = {
    val temp = "Partner Name"
    Query[String, Client](sql, None).toQuery0(temp)
}

I thought it was the problem with an encoding and I tried to fix it

def partnerClients(partnerName: String) = {
    val temp = new String(partner.getBytes("Windows-1251"), "UTF-8")
    Query[String, Client](sql, None).toQuery0(temp)
}

But the result is the same - the empty set.

1 Answer 1

1

I use this answer to turn on logging and found out that parameters sent by me contain whitespaces. Trim function fixed it

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.