Page 1 of 1

Copperspice 1.7.0 SQLite QString Blob

Posted: Tue Nov 17 2020 3:13 pm
by crispina
I have been developing a small (personal) talking diary application for Linux called EventTalker (https://github.com/crispinalan/) with Debian 10 CopperSpice 1.6.3.

I have now started to look at using CopperSpice 1.7.0. I noticed an issue with my dbManager code written to insert, update etc. events into an SQLite database. Basically in my AddEvent method with 1.6.3 I was able to use code like.

Code: Select all

QString title = event.m_title;
query.bindValue(":titlein",title);
where query is an

Code: Select all

QSqlQuery query;
and title is inserted into the database as a TEXT type. After migrating to 1.7.0 I observed that with the same code the title is inserted into the database as a BLOB. I checked the SQLite documentation and a TEXT value is a text string, stored using the encoding (UTF-8, UTF-16BE or UTF-16LE). So my immediate thought was to use an UTF-8 encoding with the query bindValue line as shown below.

Code: Select all

query.bindValue(":titlein",title.toUtf8());
This worked. However it raises some questions about QString and changes from 1.6.3 to 1.7.0. This is my first CopperSpice project (and forum post) and I am still learning about the core design and functionality. I have noticed that there is a CsString library which supports encoding. When and how would you use CsString as opposed to QString in a query.bindValue()?

Thank you for all the great work that has been done with CopperSpice.

Re: Copperspice 1.7.0 SQLite QString Blob

Posted: Mon Nov 30 2020 6:07 am
by ansel
Thanks for reporting this. This sounds odd and like something we need to take a look at. Do you by chance have a way to test this using our other database drivers like PostgreSQL or MySQL/MariaDB?

As to your question about CsString vs QString, since you are using CopperSpice you should be using QString exclusively. CsString is provided as a standalone library for use in applications that do not need any of the other functionality from CopperSpice. The two string types are convertible to each other to support interoperability but QString is preferred whenever it is available.

Re: Copperspice 1.7.0 SQLite QString Blob

Posted: Tue Dec 01 2020 7:16 pm
by crispina
I have only used the Sqlite database driver and so cannot comment on PostgreSQL or MySQL/MariaDB drivers. The source code that I am using with CopperSpice 1.7.0 (dbmanager.cpp) can be found on the Talk Calendar github page (https://github.com/crispinalan/).

Thank you for the information regarding CsString vs QString.