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>
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
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
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
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
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