Skip to content

v.db.select: Rewrite JSON output using parson library#7076

Open
saket0187 wants to merge 2 commits intoOSGeo:mainfrom
saket0187:v.db.select-add-parson
Open

v.db.select: Rewrite JSON output using parson library#7076
saket0187 wants to merge 2 commits intoOSGeo:mainfrom
saket0187:v.db.select-add-parson

Conversation

@saket0187
Copy link
Contributor

This PR addresses #6969.
(I know there is already a PR, but it seems inactive for one week and not making progress, so I made this PR.)

This PR rewrites v.db.select using the parson wrapper. I have tried to write it in a cleaner and more readable way. Also, I have added one extent test as @wenzeslaus asked for in the other PR. However, I didn't add the CSV one he requested because I think there are enough tests that check format=csv in the test_v_db_select_json_csv.py file. So I haven't added that.

Apart from that, I have changed assertLooksLike to assertEqual for the JSON test because using that was giving an error due to a difference in structure, I think (see below):

image If using assertLooksLike is really needed, then we will have to update `out_json`, but I think it's good as it is—clean and compact. Adding a new style will only increase the number of lines in the file.

After this, all the test cases are passing successfully on my side.

Finally, this is how the JSON output looks (just in case you want to see):

{
    "info": {
        "columns": [
            {
                "name": "cat",
                "sql_type": "INTEGER",
                "is_number": true
            },
            {
                "name": "MAJORRDS_",
                "sql_type": "DOUBLE PRECISION",
                "is_number": true
            },
            {
                "name": "ROAD_NAME",
                "sql_type": "CHARACTER",
                "is_number": false
            },
            {
                "name": "MULTILANE",
                "sql_type": "CHARACTER",
                "is_number": false
            },
            {
                "name": "PROPYEAR",
                "sql_type": "INTEGER",
                "is_number": true
            },
            {
                "name": "OBJECTID",
                "sql_type": "INTEGER",
                "is_number": true
            },
            {
                "name": "SHAPE_LEN",
                "sql_type": "DOUBLE PRECISION",
                "is_number": true
            }
        ]
    },
    "records": [
        {
            "cat": 1,
            "MAJORRDS_": 1,
            "ROAD_NAME": "NC-50",
            "MULTILANE": "no",
            "PROPYEAR": 0,
            "OBJECTID": 1,
            "SHAPE_LEN": 4825.3694050000004
        },
        {
            "cat": 2,
            "MAJORRDS_": 2,
            "ROAD_NAME": "NC-50",
            "MULTILANE": "no",
            "PROPYEAR": 0,
            "OBJECTID": 2,
            "SHAPE_LEN": 14392.589058
        },
        {
            "cat": 3,
            "MAJORRDS_": 3,
            "ROAD_NAME": "NC-98",
            "MULTILANE": "no",
            "PROPYEAR": 0,
            "OBJECTID": 3,
            "SHAPE_LEN": 3212.9812419999998
        }
    ]
}

for extent

{
    "extent": {
        "n": 201971.85945864301,
        "s": 148158.10953755351,
        "w": 123971.19498978264,
        "e": 209096.26602160058
    }
}

@saket0187 saket0187 changed the title v.db.select: Add parson lib support v.db.select: Rewrite JSON output using parson library Feb 11, 2026
@github-actions github-actions bot added vector Related to vector data processing Python Related code is in Python C Related code is in C module tests Related to Test Suite CMake labels Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C Related code is in C CMake module Python Related code is in Python tests Related to Test Suite vector Related to vector data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant