5

I'm using SQLX and PQ to query an SQL database with PostGress. I'm using the function Select from SQLX with bindvars but PQ panics with

pq: got 1 parameters but the statement requires 0.

 query = `
    SELECT 
        count(*) AS count 
    FROM 
        ledger 
    WHERE 
        enterprise_id=($1)
 `
 var stat singleStat

 err = db.Select(&stat, query, enterpriseID)
braaterAfrikaaner
  • 1,072
  • 10
  • 20
Luis Serra
  • 131
  • 1
  • 7

1 Answers1

1

If anyone gets to here, I found out the answer by digging a bit on the pq source code. To use prepared parameters with Crate, it requires driver to send the parameters as binary before preparing the statement; answering with the types of the parameters.

To accomplish this, add 'binary_parameters=yes' to your connection string. Like:

"user=crate dbname=test binary_parameters=yes"

Luis Serra
  • 131
  • 1
  • 7