[odb-users] Problem with QDate and Sqlite when it's mapped with TEXT type

علی دانش adanesh at noornet.net
Tue Sep 8 04:35:07 EDT 2015


Hi Boris,
Thanks for your reply. The problem is related to my operating system locale, because Qt uses operating system locale. My OS locale is Persian.

odb\qt\date-time\sqlite\qdate-traits.hxx, Line 64:

std::string s (v.toString ("yyyy-MM-dd").toLatin1 ().constData ());

must be changed to:

std::string s(QLocale(QLocale::English).toString(v, "yyyy-MM-dd").toLatin1().constData());

There are some other places that must be corrected.
Best regards,

Ali

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com]
Sent: Monday, September 7, 2015 9:04 PM
To: علی دانش
Cc: odb-users at codesynthesis.com
Subject: Re: [odb-users] Problem with QDate and Sqlite when it's mapped with TEXT type



Hi Ali,



> I have a problem with QDate and sqlite database when QDate is mapped

> with TEXT type (default behavior). When it is mapped with INTEGER

> there is no problem, but when it is mapped with TEXT, it is persisted

> correctly, but retrieved incorrectly (it looks like an uninitialized

> variable!)



We have the TEXT mapping exercised in the ODB test suite and everything works correctly, including on Windows. So we will have to do a little debugging to figure out what's going on. Specifically, can you set the breakpoint in file:



libodb-qt/odb/qt/date-time/sqlite/qdate-traits.hxx



Line 37 (the 'if (is_null)' statement in set_value()). Then run your test and see what happens there. Specifically, you want to look at i.data() and 'n' and verify that they describe the correct string representation of the date.



Boris


More information about the odb-users mailing list