v.db.select: Rewrite JSON output using parson library#7076
Open
saket0187 wants to merge 2 commits intoOSGeo:mainfrom
Open
v.db.select: Rewrite JSON output using parson library#7076saket0187 wants to merge 2 commits intoOSGeo:mainfrom
saket0187 wants to merge 2 commits intoOSGeo:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.pyfile. 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):
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 } }