Order by doesn't seem to work through Go SDK

Hello,
I’m trying to paginate through the list of sorted identities. An identity has a first_name and last_name.

I am constructing the query based on the parameters provided in the simplest case the query looks like this:

SELECT x.*, meta(x).id as id FROM %s x WHERE x.type="identity"  ORDER BY $orderBy ASC OFFSET $offset LIMIT $limit
Parameters used: map[limit:10 offset:0 orderBy:x.first_name] 

(the %s will be replaced by the bucket name)

But for some reason the ordering doesn’t work. If I copy-paste the same query in the web console then ordering works fine. I’m at a loss. Any help would be greatly appreciated.

For completion: Here is how an example of an identity:

{
  "id": "0091d400-ba25-11eb-b15b-000d3a8356e9",
  "type": "identity",
  "first_name": "test1",
  "last_name": "test",
  "is_cockpit_user": false,
  "credentials": [
    {
      "email": "test1@test.com",
      "password": "",
      "is_validated": false,
      "main_for_tenant": [
        {
          "tenant_id": "610",
          "created_at": "0001-01-01T00:00:00Z"
        }
      ]
    }
  ]
}

ORDER BY expression can’t be parameterized. In next release ORDER BY direction/nulls position can be parameterized (MB-45957), but will not able to use index order.

As described by MB-45957, One can use dynamic order as ORDER BY x.[$orderBy] . This will not use index order. $orderBy must be string of single field. If need nested dynamic fields ORDER BY x.[$f1].[$f2]

To use index order, need to know expression during prepare time, parameters are not available during prepare time.

SELECT x.*, meta(x).id as id 
FROM %s x 
WHERE x.type="identity"  
ORDER BY x.[$orderBy] ASC
 OFFSET $offset 
LIMIT $limit

Using OFFSET and Keyset in N1QL - The Couchbase Blog might helpful.

Ah, I see. Will try that. Thanks a lot for the fast response.