[Interest] Qt Sql BLOB data converting

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Mon Nov 28 19:44:10 CET 2022


Am 28.11.2022 um 19:40 schrieb Christian Ehrlicher:
>
> Am 28.11.2022 um 19:16 schrieb Yauheni Pervenenka via Interest:
>> Thiago, hello, thanks for your reply, sorry have no instructions for
>> create and insert, but have data base with one value which can't be
>> parsed correct(db is cut to one value for provide example)
>>
>> https://bugreports.qt.io/browse/QTBUG-108992
>>
> Your database looks strange to me - even though your column type
> according to the schema is BLOB:
>
> sqlite> .schema
> CREATE TABLE IF NOT EXISTS "test" (
>         "value" BLOB NOT NULL
> );
>
> the return value of sqlite3_column_type() is SQLITE_TEXT (3).
>
> Therefore the return value is treated as string and the data is screwed
> up. If I change the return value to SQLITE_BLOB (4) in the debugger, all
> is correct:
>
> qDebug() << value.toByteArray().toHex();
>
> -->
>
> "763130492d46ab4c9c7bb0e9789b29c3ab1e4723dea6c8e5d2f9b266a275e1fbe4a6"

Even the sqlite command line utility is confused:

sqlite> select sql from sqlite_schema where tbl_name = "test";
CREATE TABLE "test" (
         "value" BLOB NOT NULL
)
sqlite> select typeof(value) from test;
text


Christian



More information about the Interest mailing list