sqlitebrowser / sqlitebrowser/sqlitebrowser

[Bug]: Database cell type not updated properly when copy/pasting blob data

Ouverte
#3,307 15 commentaires 0 réactions 1 personne assignée Voir sur GitHub

@mgrojo y travaille déjà.

Depuis le 4/8/2023.

bug
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:
  1. 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");
  1. Open the database in DB4S and go to the "Browse Data" tab
  2. Use ctrl+c and ctrl+v to copy the BLOB value over the TEXT value
  3. Write the changes to the database
Verifying through sqlite3 cli
  1. Open the database sqlite3 /path/to/database.db
  2. 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

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.