Commit Graph

1494 Commits

Author SHA1 Message Date
silverqx 0ee020d09e added section comment 2023-07-01 08:09:35 +02:00
silverqx fe56121649 changed order of friend declaration 2023-06-30 16:16:16 +02:00
silverqx 651594754d removed useless #include 2023-06-30 16:15:39 +02:00
silverqx aad52a89c8 changed qt_timezone default to Qt::UTC
Previously, it was the QtTimeZoneType::DontConvert that implied the
Qt::LocalTime timezone spec.

Setting this to the Qt::UTC by default is the only way to have the
maximum level of interoperability between TinyORM and other libraries
and services.

 - updated comments in docs and source code
2023-06-29 12:07:42 +02:00
silverqx 21530fa915 removed const in ModelsCollection callbacks
It allows to call eg. getRelationValue() inside these callbacks and
an user can also use const Model *const if needed, so it's much more
flexible.

Also I left const Model * in documentations, I didn't remove the const
from docs, it's on pupropse to show that it's possible.
2023-06-28 15:08:08 +02:00
silverqx dc4dd7c1c7 whitespaces 2023-06-28 14:07:24 +02:00
silverqx d10a72e359 removed todo tasks 2023-06-28 13:57:37 +02:00
silverqx 556eb8df00 made dozens of methods const 2023-06-28 13:55:15 +02:00
silverqx db3aa6bae9 used reserve 2023-06-28 13:51:13 +02:00
silverqx c483f7dc06 used static variable access 2023-06-28 13:50:44 +02:00
silverqx 19dafd27eb added inline 2023-06-28 13:48:55 +02:00
silverqx 3a04a1eca1 fixtypo 2023-06-28 13:48:30 +02:00
silverqx e695c3f5c9 added comment 2023-06-27 17:41:11 +02:00
silverqx 379916e4bf added section comment 2023-06-27 15:57:30 +02:00
silverqx 929ff261b9 whitespace 2023-06-27 15:46:40 +02:00
silverqx fc41152b55 made relation stores non-polymorphic
They don't need to be polymorphic as any method is not virtual and
stores are managed using shared_ptr-s.
2023-06-26 20:26:54 +02:00
silverqx 5fae87f8fc bugfix missing template parameter for toJson
Missing the PivotType to correctly serialize models collection
with belongs-to-many relations only, eg. after calling the getRelation()
or getRelationValue().
2023-06-26 14:39:20 +02:00
silverqx 14c67efb6f workaround for null QVariant bug for QJson 🫤
Fix the null QVariant bug for QJsonDocument, replace null QVariant-s
with the QVariant(nullptr).

The QJsonValue should return null for null QVariant-s but it doesn't,
even if the Qt's QJsonValue::fromVariant() documentation explicitly
states this behavior, it says: "If QVariant::isNull() returns true,
a null QJsonValue is returned or inserted into the list or object,
regardless of the type carried by QVariant.".

But this is not happening, it returns 0 for numbers, "" for QString and
QDateTime. 🫤

 - updated unit tests
 - added unit test method to test this behavior, to test null for all
   QVariant types
2023-06-26 09:09:59 +02:00
silverqx b06e00021d added support for U format in serialization
The toMap, toVector, and toJson accepts {CastType::CustomQDateTime, "U"}
and returns unixtimestamp.
2023-06-25 19:14:17 +02:00
silverqx de9cc281a9 changed defaults to Compact for toJson()
Changed from QJsonDocument::Indented to Compact.

 - updated docs
2023-06-25 16:42:43 +02:00
silverqx 987a989c7d bugfix in originalIsEquivalent() 2023-06-25 14:41:00 +02:00
silverqx 3e1be3b029 updated comment 2023-06-25 14:21:53 +02:00
silverqx 0cea374f53 fixtypo 2023-06-25 09:24:01 +02:00
silverqx 0c8b6c5afb removed todo task 2023-06-23 14:18:19 +02:00
silverqx 4ae13438db removed todo task 2023-06-23 14:06:03 +02:00
silverqx 1b0ccb9721 whitespace 2023-06-22 09:06:33 +02:00
silverqx 06647e8b38 added models serialization to JSON 🔥🚀
It serializes complete models and model collections with all relations
including pivot models.

 - added unit tests
2023-06-20 14:13:51 +02:00
silverqx b67f25807f removed unused #include 2023-06-19 16:49:11 +02:00
silverqx 1be83c85db added comment 2023-06-19 14:26:27 +02:00
silverqx 7d83572bbc added user serialization override support
The user can override serializing of date and datetime, each separately.

 - added unit tests
2023-06-19 08:44:53 +02:00
silverqx b41c92fe90 whitespaces 2023-06-18 22:33:34 +02:00
silverqx 74906ebb86 allowed serializeDate/Time() override
The user can override these methods in the Derived models.
2023-06-18 22:29:06 +02:00
silverqx ba3e9560d9 bugfix Model::operator==()
Thanks to the CRTP the user doesn't have to define operator==() in every
model, the u_xyz data members are compared here. I don't like it though,
one caveat of this is that if a user defines the operator==() then these
data members will be compared twice.
2023-06-18 21:53:50 +02:00
silverqx 53bf8cedb7 fixtypo 2023-06-18 21:31:06 +02:00
silverqx fa257e4121 added [[noreturn]] attribute to throw methods 2023-06-18 18:08:17 +02:00
silverqx 0a8ac83b20 added IWYU pragma 2023-06-18 17:43:29 +02:00
silverqx cffc9623ec wrapped registerQMetaTypesForQt5() in #if 2023-06-18 16:32:39 +02:00
silverqx e28c4e990a called Q_DECLARE_METATYPE only for Qt 5 2023-06-18 16:32:05 +02:00
silverqx 03ff6d0fb7 registered QMetaType equal comparators 2023-06-18 16:22:52 +02:00
silverqx 1ebae9524f added Q_DECLARE_METATYPE for Qt 5 2023-06-18 14:43:50 +02:00
silverqx 1a9d0d1143 used QVector::size_type in HasAttributes 2023-06-17 20:55:27 +02:00
silverqx 268a9371e8 added typename 2023-06-17 20:54:55 +02:00
silverqx 8f68b8e0a1 removed useless typename 2023-06-17 19:50:11 +02:00
silverqx 4b66906ae5 whitespace 2023-06-17 19:45:13 +02:00
silverqx a5fc09a4fb bugfix select constraints and belongs-to-many
I have to write a note here, this !relation.name.contains(DOT) bugfix
was unbelievable, it took me a whole day of debugging, writing unit
tests, and figuring out how to solve this problem. I wrote dozen of
lines to make it work but at the end I started removing what was not
needed and ended with this one condition. 😮🙃 If the relation name is a
nested relation, then the select constraints lambda will not be
generated and will be nullptr, so will be skipped here, the problem was
that the getRelatedTableForBelongsToManyWithVisitor() could not be
invoked correctly because it's a nested relation. The
getRelatedTableForBelongsToManyWithVisitor() will be visited or resolved
later, right before it will be needed and it will be done during
relation->getQuery().with(std::move(nested)); in the
eagerLoadRelationVisited(), the magic is done in the
relationsNestedUnder() when the nested relation is unwrapped.

 - added bunch of unit tests for this case
2023-06-17 19:32:30 +02:00
silverqx db28ad3d3e used emplaceBack on Qt 6 2023-06-17 17:31:33 +02:00
silverqx a289faf0d8 added const to ModelsCollection methods
Revisited all methods.
2023-06-16 16:59:23 +02:00
silverqx d724527bb3 used emplaceBack for Qt containers 2023-06-16 16:22:46 +02:00
silverqx 49e24c0c16 added HASH_ global string constant for "hash" 2023-06-16 15:09:58 +02:00
silverqx d385e1be24 added noexcept to getUserXyz() getters 2023-06-16 14:51:03 +02:00