-
Notifications
You must be signed in to change notification settings - Fork 691
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
Do not convert BLOB value to base64 #1691
Comments
I agree that this part of rqlite could use improvement. I'm trying to decide the best way to enhance the API to do so. However can't you use the |
SQLite has affinity type, so even if the column type is 'BLOB', it can still store 'TEXT'. HTTP Request Body[
"SELECT blob FROM all_types where id >= 12 LIMIT 2;"
] HTTP Response Body{
"results": [
{
"columns": [
"blob"
],
"types": [
"blob"
],
"values": [
[
"/+4i"
],
[
"text"
]
]
}
]
} |
Can I ask what your use case is, such that you could end up writing text to a blob field? If you control the application writing to rqlite, don't you control what goes into the columns? Also, are you aware of the Since SQLite supports storing any value in any column, I want to make rqlite easy to use in this mode. But if I can learn more about your use case, it will help me provide a better solution. |
This is a related issue: #1345 |
I am writing a database manager which supports connection to rqlite. When rqlite return data, I can't tell at all if it's BLOB or TEXT because it's always JSON(String). This is the solution in Cloudflare D1, which is very similar to rqlite, but we can use {
"result": [
{
"results": [
{
"id": 1,
"real": 1.23456555,
"text": "Hello world",
"blob": [
255, 255, 128
]
}
],
"success": true,
...
}
],
...
} |
An alternative idea is to add a new (optional) key to the responses. The key would be I would make it optional because it would add a lot of extra data to the response, and most of it might be repeated. |
Response would then be: {
"results": [
{
"columns": [
"blob"
],
"types": [
"blob"
],
"vtypes": [
[
"blob"
],
[
"text"
]
],
"values": [
[
"/+4i"
],
[
"text"
]
]
}
]
} |
Formal proposal for a solution here: #1701 I'm also considering a flag targeted at this use case, which would enable a different encoding for BLOB types. |
@wyhaya -- I can't change existing behaviour as it would be a breaking change. However I could add support for an optional query-time flag, curl -G 'localhost:4001/db/query?pretty&blob_array' --data-urlencode 'q=SELECT * FROM foo'
{
"results": [
{
"columns": [
"data"
],
"types": [
"blob"
],
"values": [
[
[20, 5, 2, 6]
]
]
}
]
} Any thoughts? |
Thanks @otoolep, This completely meets my needs. |
Minor tweak, the URL flag will be |
Is your feature request related to a problem? Please describe.
When querying via the HTTP API, BLOB are always encoded as base64 and represented as a String in JSON, making it impossible for us to differentiate whether it is a BLOB or a TEXT.
Describe the solution you'd like
There should be a way to distinguish between BLOB and TEXT types.
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: