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

Support for telling apart bytes vs base64 text in any columns #1345

Closed
refi64 opened this issue Jul 14, 2023 · 2 comments
Closed

Support for telling apart bytes vs base64 text in any columns #1345

refi64 opened this issue Jul 14, 2023 · 2 comments

Comments

@refi64
Copy link

refi64 commented Jul 14, 2023

# Create a table with 'any'
$ xh localhost:4001/db/request '[0]'='CREATE TABLE anything (a any) STRICT'
HTTP/1.1 200 OK
Content-Length: 34
Content-Type: application/json; charset=utf-8
Date: Fri, 14 Jul 2023 00:20:45 GMT
X-Rqlite-Version: v7.21.4

{
    "results": [
        {
            "last_insert_id": 2
        }
    ]
}
# Insert a blob
$ xh localhost:4001/db/request '[0]'="INSERT INTO anything VALUES (x'c0fe')"
HTTP/1.1 200 OK
Content-Length: 52
Content-Type: application/json; charset=utf-8
Date: Fri, 14 Jul 2023 00:21:14 GMT
X-Rqlite-Version: v7.21.4

{
    "results": [
        {
            "last_insert_id": 1,
            "rows_affected": 1
        }
    ]
}
# Insert some text
$ xh localhost:4001/db/request '[0]'="INSERT INTO anything VALUES ('test')"
HTTP/1.1 200 OK
Content-Length: 52
Content-Type: application/json; charset=utf-8
Date: Fri, 14 Jul 2023 00:22:19 GMT
X-Rqlite-Version: v7.21.4

{
    "results": [
        {
            "last_insert_id": 2,
            "rows_affected": 1
        }
    ]
}
# Get our values back
$ xh localhost:4001/db/request '[0]'='SELECT * FROM anything'
HTTP/1.1 200 OK
Content-Length: 76
Content-Type: application/json; charset=utf-8
Date: Fri, 14 Jul 2023 00:22:56 GMT
X-Rqlite-Version: v7.21.4

{
    "results": [
        {
            "columns": [
                "a"
            ],
            "types": [
                "any"
            ],
            "values": [
                [
                    "wP4="
                ],
                [
                    "test"
                ]
            ]
        }
    ]
}

If I just go based off of the response, there's no way for me to tell if wP4= is supposed to be a string or a blob; the only indicator is that it looks like base64, which could be valid in unintentional cases as well.

@otoolep
Copy link
Member

otoolep commented Feb 25, 2024

Proposed solution in #1701

@otoolep
Copy link
Member

otoolep commented Feb 26, 2024

Fixed in #1703

@otoolep otoolep closed this as completed Feb 26, 2024
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