Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Field names and values order doesn't match for JSON output #569

Closed
ipsusila opened this issue Jul 4, 2020 · 1 comment
Closed

Field names and values order doesn't match for JSON output #569

ipsusila opened this issue Jul 4, 2020 · 1 comment

Comments

@ipsusila
Copy link

ipsusila commented Jul 4, 2020

The order of field names and field values doesn't match for SCAN query with JSON output. Try the following in tile38-cli

>SET fleet truck1 FIELD speed 90 FIELD age 21 POINT 33.5123 -112.2693
>SCAN fleet match truck*
{"ok":true,"fields":["age","speed"],"objects":[{"id":"truck1","object":{"type":"Point","coordinates":[-112.2693,33.5123]},"fields":[90,21]}],"count":1,"cursor":0,"elapsed":"170.4µs"}

Reformated JSON output is shown below:

{
    "ok": true,
    "fields": ["age", "speed"],
    "objects": [{
        "id": "truck1",
        "object": {
            "type": "Point",
            "coordinates": [-112.2693, 33.5123]
        },
        "fields": [90, 21]
    }],
    "count": 1,
    "cursor": 0,
    "elapsed": "170.4µs"
}

As shown above, the field names order is ["age", "speed"] and the field values order is [90, 21].
Tried both for version 1.21.1 and master branch.

@tidwall
Copy link
Owner

tidwall commented Jul 4, 2020

I found the issue and fixed it. It seems to have occurred specifically with JSON output. RESP output and other retrieval commands did not encounter this problem.

tidwall added a commit that referenced this issue Jul 8, 2021
This commit fixes an issue that happens when running SCAN on a
collection that has objects with fields, causing field values
to be mismatched with their respective keys.

This only occured with json output, and is a regression from #534.

Fixes #569
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants