Commit Graph

670 Commits

Author SHA1 Message Date
silverqx 5bc038e80a updated Copyright to Silver Zachara 2023-08-19 14:05:01 +02:00
silverqx e775fde936 suppressed warnings from QStringBuilder
Suppressed warnings from QStringBuilder about can be made constexpr if
the external:templates- is defined for MSVC.
2023-08-18 17:52:39 +02:00
silverqx f7db5269fc tests fixed comparing signed/unsigned integers 2023-08-18 17:52:39 +02:00
silverqx c86ba1efbc tests throw if TOM_TESTS_ENV is production 2023-07-24 16:25:47 +02:00
silverqx 54dc973806 tests bad static keyword position 2023-07-24 16:25:46 +02:00
Alonso Schaich 2a23991ae5 Include exception headers (#17)
include exception headers (silverqx/TinyORM#16)

The querybuilders' unit tests fail to compile due to some Exception
classes being undefined if ORM compilation is disabled via cmake.

The undefined exceptions are actually being built as part of the
querybuilder. However, the unit tests deep-end on models/user.hpp to
include the header files for the exception classes they are using,
but the corresponding include directive is skipped for builds that
disable ORM.

Close #16
---------

Co-authored-by: Silver Zachara <silver.zachara@gmail.com>
2023-07-24 16:16:23 +02:00
silverqx c8a7060465 tests added serialize tests
Test a custom pivot model with appends feature.
2023-07-17 22:20:23 +02:00
silverqx 86c96529a5 added hasVisible() and hasHidden()
- added unit test
2023-07-15 13:11:21 +02:00
silverqx 9db7224bc7 fixed clang-tidy warning 2023-07-14 08:42:08 +02:00
silverqx 0b43b25e03 added u_visible/hidden modifier method overloads
- updated unit tests
2023-07-13 12:12:25 +02:00
silverqx 89d95269c2 added new u_touches modifier methods
- added unit test
2023-07-13 11:01:00 +02:00
silverqx 0028253222 tests used another row
Collision with TinyOrmPlayground in timestamp columns.
2023-07-12 10:37:39 +02:00
silverqx 85ed93b834 tests whitespaces 2023-07-12 10:36:27 +02:00
silverqx 16a69ac4d0 used std::addressof() everywhere
Used instead of reinterpret_cast<uintptr_t>(&)
2023-07-11 19:08:00 +02:00
silverqx 1ecf628a7a tests bugfix removed illogical QVERIFY() 2023-07-11 19:05:31 +02:00
silverqx 6cf15e02fc used a new Progress constant everywhere 2023-07-11 18:00:06 +02:00
silverqx 0bb7a9c331 renamed exceptions 2023-07-11 17:37:28 +02:00
silverqx 411a635e6c added Appending Values To JSON support 🕺
These Appends are appended to the serialized models during the toMap(),
toVector(), or toJson() methods call.

Appends names are and must be mapped using the u_mutators hash map
(in the same way like u_relations) because c++ doesn't support advanced
reflection.

Appends are mapped to methods (can be protected) that return
the Casts::Attribute. This Casts::Attribute is a wrapper to return
a new attribute value.

Appends accept u_visible and u_hidden.

For the Appends that return QDate or QDateTime are the counterpart
serializeDate() or serializeDateTime() methods called.

 - added unit tests
2023-07-11 17:14:20 +02:00
silverqx d5f109b0f4 whitespaces 2023-07-11 08:31:11 +02:00
silverqx d4444e4c28 added Hiding Attributes support
A user can define the u_visible and u_hidden std::set static data
member for visible and hidden attributes on his models and they will be
used during serialization.

The relationships and also u_snakeAttributes are correctly taken into
account.

 - added unit tests
 - added example to Models::Torrent
2023-07-11 08:31:06 +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 0787c5ab16 tests toMap, toVector, toJson for relation only 2023-06-26 14:40:08 +02:00
silverqx ad97c866b4 tests changed test methods order 2023-06-26 09:44:22 +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 fe077cea6b tests reverted commented code 2023-06-22 14:15:42 +02:00
silverqx 6733cf9069 tests shorten folder name to avoid long paths
Second step to preserve commit history.
2023-06-22 14:13:33 +02:00
silverqx f54da06b47 tests shorten folder name to avoid long paths 2023-06-22 14:12:45 +02:00
silverqx 38ab1873d3 tests commented test methods 2023-06-22 12:04:52 +02:00
silverqx 2ed69e44c0 tests commented test methods 2023-06-22 11:54:20 +02:00
silverqx 4cd0ae1ae7 tests divided to three test cases
To minimize memory consumption during compilation because MSYS2 g++
on GitHub Actions exhausted memory.
2023-06-22 09:40:19 +02:00
silverqx a923fb6546 tests added section comment 2023-06-22 09:07:53 +02:00
silverqx ab767ebff1 tests divided to two test cases
To minimize memory consumption during compilation because MSYS2 g++
on GitHub Actions exhausted memory.
2023-06-21 12:53:03 +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 f68fab02df tests whitespaces 2023-06-20 12:49:27 +02:00
silverqx 37735f88e6 tests added test for empty belongs-to-many 2023-06-20 10:22:00 +02:00
silverqx 5ef758a6ef tests changed attributes order 2023-06-20 10:20:37 +02:00
silverqx 2648b087b8 tests removed unused using alias 2023-06-19 09:42:36 +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 5f8f844672 used ranges::find instead of std version 2023-06-18 14:45:15 +02:00
silverqx 5fda855663 bugfix Qt5 ambiguous overload 2023-06-18 14:44:38 +02:00
silverqx 1a9d0d1143 used QVector::size_type in HasAttributes 2023-06-17 20:55:27 +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 b83d3cee27 tests added comment 2023-06-17 18:48:01 +02:00
silverqx 5bc0958598 tests rename unit test method 2023-06-17 18:47:50 +02:00
silverqx c60dc1b0da tests added more seed data, to test relations
Added a new roles belongs-to-many relation to the Tag model to test
eager or lazy loading with select constraints.

 - updated affected unit tests
2023-06-17 17:27:56 +02:00
silverqx fc3ca5450a tests updated comment 2023-06-17 16:18:59 +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