Gocb and Couchbase Console give different result on LIKE query

i have a query that looks like :

Couchbase Console version :

select bucket_name.* from bucket_name where type = 0 and text like '%heineken%' and timestamp > 1563037200 and timestamp < 1563469200 limit 25

Gocb version :

query := "select bucket_name.* from bucket_name where type = 0 and text like '%$1%' and timestamp > $2 and timestamp < $3 limit $4"

the Couchbase Console give expected result while the Gocb version are not (even more like the like query are not used, the return content doesn’t contain heineken word)

You can’t have query parameter inside the string, that will not replace. You really looking for $1 in the string instead of heineken.
If you want you can do something like this text LIKE $1 and pass $1 that has prefix/postfix as % (i.e. $1 = “%heineken%”)

1 Like