Passing array of array in a IN condition placeholder with go sql

462 Views Asked by At

Introduction

I am encountering a problem when I attempt to pass several couple of values in a IN condition. When I attempt the query in the postgres console it works fine but it fails when executed in go.

The situation

The query I'm attempting to execute is of the following form :

select * 
from someTable 
where (someTable.colA, someTable.colB) in ($1)

In the console trying

select * 
from someTable 
where (someTable.colA, someTable.colB) in ((val1a, val1b), (val2a, val2b))

works flawlessly but not when I attempt it in fo

What I tried

The only thing that got me somewhere was using pq.Array.

query := "select * from someTable where (someTable.colA, someTable.colB) in ($1)"
pgDb.Query(query, pq.Array([][]interface{}{{"030043B", 49}, {"030002B", 49}}))

The error I receive is in french but roughly translated it would probaly correspond to input of composite type columns is not implemented (original message l'ajout de colonnes ayant un type composé n'est pas implémenté).

The last solution I could do is to manually str replace in the query with my params but I'd rather avoid. If it comes to that it's fine, this is data comming from the DB with no user input anywhere, there is no option for injecting here.

Thank you for your time

0

There are 0 best solutions below