sqlitebrowser / sqlitebrowser/sqlitebrowser
[Bug]: Database cell type not updated properly when copy/pasting blob data
@mgrojo y travaille déjà.
Depuis le 4/8/2023.
- Langage dominant
- C++
- Étoiles
- 24.6k
- Forks
- 2.4k
- Merge moyen
- 3 j 49 min
- PR mergées (30 j)
- 3
Description
What did you do?
When copying BLOB data into cells in the database which contain TEXT data, the BLOB will be copied into the cell and DB4S will display the type as BLOB, but when the database is read through the sqlite3 command line or python library it will be read as an empty TEXT field.
Steps to Reproduce:
- Create a new database and initialize as follows
CREATE TABLE "test_table" ( "field" BLOB );
INSERT INTO "test_table" ("field") VALUES (X'DEADBEEF');
INSERT INTO "test_table" ("field") VALUES ("String");
- Open the database in DB4S and go to the "Browse Data" tab
- Use
ctrl+candctrl+vto copy theBLOBvalue over theTEXTvalue - Write the changes to the database
Verifying through sqlite3 cli
- Open the database
sqlite3 /path/to/database.db - Dump raw data with
.dump
-- Output abridged
INSERT INTO test_table VALUES(X'deadbeef');
INSERT INTO test_table VALUES('ޭ��'); -- BLOB field is output as corrupt TEXT
Verifying through python's sqlite3 module
Using the following script
import sqlite3
conn = sqlite3.connect('/path/to/database.db')
cursor = sqlite3.Cursor(conn)
cursor.execute("SELECT field FROM test_table")
for row in cursor.fetchall():
print(type(row[0]), row[0])
Depending on the exact binary data in the BLOB field the script will either crash with sqlite3.OperationalError: Could not decode to UTF-8 column 'field' with text'����' or will output the bytes field directly interpreted as UTF-8.
What did you expect to see?
I expected the BLOB value to be exactly copied over the text cell so that the two output lines of the .dump command would be identical.
What did you see instead?
The BLOB data was saved as corrupt text. Depending on how this data is retrieved, it either comes out as garbled text or crashes the program due to invalid UTF-8 encoding.
DB4S Version
3.12.2
What OS are you seeing the problem on?
Linux
OS version
Arch Linux
Relevant log output
No response
Prevention against duplicate issues
- I have searched for similar issues
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Évaluation
Cette issue n'a pas encore été évaluée.