Changeset View
Standalone View
src/tools/KDbUtils.cpp
Show First 20 Lines • Show All 138 Lines • ▼ Show 20 Line(s) | |||||
139 | 139 | | |||
140 | QDateTime KDbUtils::stringToHackedQTime(const QString &s) | 140 | QDateTime KDbUtils::stringToHackedQTime(const QString &s) | ||
141 | { | 141 | { | ||
142 | if (s.isEmpty()) { | 142 | if (s.isEmpty()) { | ||
143 | return QDateTime(); | 143 | return QDateTime(); | ||
144 | } | 144 | } | ||
145 | // kdbDebug() << QDateTime( QDate(0,1,2), QTime::fromString( s, Qt::ISODate ) | 145 | // kdbDebug() << QDateTime( QDate(0,1,2), QTime::fromString( s, Qt::ISODate ) | ||
146 | // ).toString(Qt::ISODate); | 146 | // ).toString(Qt::ISODate); | ||
147 | return QDateTime(QDate(0, 1, 2), QTime::fromString(s, Qt::ISODate)); | 147 | return QDateTime(QDate(0, 1, 2), QTime::fromString(s, Qt::ISODateWithMs)); | ||
piggz: whats this QDate(0,1,2) ? | |||||
It's not part of this patch but here's the answer: https://phabricator.kde.org/source/kdb/browse/master/src/tools/KDbUtils.h$57 From Qt docs: QTime::QTime() Constructs a null time object. A null time can be a QTime(0, 0, 0, 0) (i.e., midnight) object, except that isNull() returns true and isValid() returns false. This commit describes the workaround: https://phabricator.kde.org/R15:21e8a3da84165d610c7ba472e43b60e1fc43b172 Otherwise in quite a few places we would have to check not only isNull but also isValid to know time valid is really null. That would be error-prone. PS: (related to this entire Date patch): The new classes KDb(Date)(Time) go much further because they are part of the parse tree. They can properly store invalid date/time elements of any kind so there's no loosing of information. This e.g. allows the user to reopen SQL and edit it. With regular Qt classes invalid values, say, in "SELECT #2018-12-37#" would turn to "SELECT NULL" or "SELECT <INVALID_DATE>" when query text is reopened. staniek: It's not part of this patch but here's the answer: https://phabricator.kde. | |||||
148 | } | 148 | } | ||
149 | 149 | | |||
150 | void KDbUtils::serializeMap(const QMap<QString, QString>& map, QByteArray *array) | 150 | void KDbUtils::serializeMap(const QMap<QString, QString>& map, QByteArray *array) | ||
151 | { | 151 | { | ||
152 | if (!array) { | 152 | if (!array) { | ||
153 | return; | 153 | return; | ||
154 | } | 154 | } | ||
155 | QDataStream ds(array, QIODevice::WriteOnly); | 155 | QDataStream ds(array, QIODevice::WriteOnly); | ||
▲ Show 20 Lines • Show All 522 Lines • Show Last 20 Lines |
whats this QDate(0,1,2) ?