ws4sqlite icon indicating copy to clipboard operation
ws4sqlite copied to clipboard

Option to return results as a list, instead of a map

Open proofrock opened this issue 1 year ago • 2 comments

The request may be:

{
        
        "resultFormat": "list",
        "transaction": [{
            "query": "SELECT * FROM folders",
            ...
        }, ...]
...

with values of list or map, by default/if absent map would be used, for retrocompatibility. If list, your result would become:

{
  "results": [
    {
      "success": true,
      "resultHeaders": ["id", "name", "position", "updated_at", "created_at"],
      "resultSet": [
        [ "default", "Default", 0.0, "2024-02-04 12:23:08", "2024-02-04 12:23:08" ]
      ]
    }
  ]
}

The new node resultHeaders would always be displayed, even in maps: currently there's no way to tell the column order, and this would give it.

proofrock avatar Feb 13 '24 07:02 proofrock

I thought about this a bit, and maybe instead of returning the data in resultSet, you can return it in another field (resultList or something else). I feel like this can simplify the code since Go's typing is a good guard rail, but sometimes it is not flexible enough.

thanhnguyen2187 avatar Feb 13 '24 09:02 thanhnguyen2187

At first glance, I don't like it... but actually, polymorphism (one key, more than one format, I mean) is not a good idea anyway. Let me think about it.

proofrock avatar Feb 13 '24 15:02 proofrock

I thought about this a bit, and maybe instead of returning the data in resultSet, you can return it in another field (resultList or something else). I feel like this can simplify the code since Go's typing is a good guard rail, but sometimes it is not flexible enough.

Yep, done it. Thanks.

proofrock avatar Feb 16 '24 19:02 proofrock