-----Original Message-----
From: Interest <interest-boun...@qt-project.org> On Behalf Of Christian
Ehrlicher
Sent: Monday, November 28, 2022 11:54 AM
To: interest@qt-project.org
Subject: Re: [Interest] Qt Sql BLOB data converting
Am 28.11.2022 um 20:31 schrieb Scott Bloom:
> -----Original Message-----
> From: Interest <interest-boun...@qt-project.org> On Behalf Of Thiago
> Macieira
> Sent: Monday, November 28, 2022 11:21 AM
> To: interest@qt-project.org
> Subject: Re: [Interest] Qt Sql BLOB data converting
>
> On Monday, 28 November 2022 10:59:47 PST Christian Ehrlicher wrote:
>> It's because of the dynamic typing feature of sqlite (
>> https://www.sqlite.org/flextypegood.html ) - even a column is created
>> as one type it can contain another one. Looks like the data was
>> inserted with the wrong type information since your blob data is for
>> sure no readable string.
> Thanks for the explanation, Christian. I can confirm that the type comes out
> correctly if it is inserted into the table AS blob, not as plaintext.
> Therefore, the problem is on the insertion side, not in the SELECT or QtSql.
>
> I've closed the task.
>
> --
> I disagree with closing it.
>
> When the cache is being created, it should use the same method for
> determining the type of a column as the record function does.
>
> First check the name of the column type, then use the enumerated type if the
> string name is empty.
This will not work when you fetch two rows with different dynamic types for a
column - there is only one record per result set. But at least we should be
consistent by directly using the already calculated values from the record
instead calling sqlite3_column_type() again.
Christian
-------
If the user/developer creates a table, where the type of a column "Actually"
changes per row, they should use a string type for the row, and do the
conversion outside of SQL, OR as you posted earlier cast the column on an
individual row select command.
But if the column is defined as a BLOB the variant should be created from a
QByteArray every time, if it's a text then QString, INT integer etc etc.
but if they did a create XXX as string, insert XXX=123 (integer) and Sqlite
can return it as a string or an integer, the QVariant should be created from an
string not an integer. The same goes if they did a create XXX as integer,
insert XXX='123'. QVariant should be created as from an integer type, and they
can do a toString on the variant if they want.
My point, dynamic types should follow C++ style "dynamic" typing not
"everything is a string until proven otherwise" typing of other languages.
Scott
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest