Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[Suggestion] Query resultset includes column info once #234

Open
PJOttCanHome opened this issue Dec 18, 2023 · 2 comments
Open

[Suggestion] Query resultset includes column info once #234

PJOttCanHome opened this issue Dec 18, 2023 · 2 comments

Comments

@PJOttCanHome
Copy link

PJOttCanHome commented Dec 18, 2023

Why? A much-less verbose query result.
Since each "cell" returned via "Query" currently includes ColumnName and ColumnType and CellValue it can become bytes-expensive for the transfer. This proposal should make it better, I hope.

New Parameter for Query Function: format=default|colheaders
format=colheaders would return a JSON string like this:

{
   "columns": [{"name":"col0","type":1},{"name":"col1","type":2},{"name":"col2","type":0}]
   "data": [
       [val0,val1,val2],
       [val0,val1,val2],
       [val0,val1,val2]
    ]
}

Each "col#" object could have the info from the "Columns" query as related to the results of this query (or at least ColName,ColType)
This returns a MUCH smaller resultset, as far as bytes transferred back.

I thank you for your time.

@justinclift
Copy link
Member

The concept sounds pretty sensible. We'd probably also need a field to indicate which data format is being used too.

One of the err... features (heh) of SQLite is that cell data doesn't need to be what the table definition declares.

So it's totally possible (and happens) for a column to be declared as one data type... but when reading results from a query to occasionally be given back a field with a mismatching data type.

Along the lines of the Peter row here:

Name Completed
Fred true
Joe false
Nancy true
Peter 33
Henry true

Note that doesn't mean we're randomly changing data types on callers for the heck of it, the API is instead returning whatever is in the database.


Your idea makes good sense for the happy path though, where there aren't any mismatches between the column definition and any individual fields in the returned data.

@PJOttCanHome
Copy link
Author

And it at least give the column name just once. Even if the column type ends up being more of a mere "suggestion" in the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants