The tiny_autoconf and tiny_dotenv qmake CONFIG were added in the TinyORM
v0.34.0. These new features allow to auto-configure TinyORM, and with
their help, the conf.pri files can be skipped entirely. The
tiny_autoconf is designed to find the vcpkg installation and tiny_dotenv
to include the .env and .env.$$QMAKE_PLATFORM files in the project's
root folder. They can be configured using qmake and environment
variables, and they also contain some guessing logic if these variables
are not defined.
These are qmake and environment variables that affect the
auto-configuration feature:
- TINY_VCPKG_ROOT - path to the vcpkg installation folder (if not
defined then it tries to use the VCPKG_ROOT environment variable)
- TINY_VCPKG_TRIPLET - vcpkg triplet to use
(vcpkg/installed/$$TINY_VCPKG_TRIPLET/); if not defined then it tries
to guess the vcpkg triplet on the base of the current compiler and OS
(QMAKESPEC)
- TINY_MYSQL_ROOT - path to the MySQL installation folder (if not
defined then it tries to guess the MySQL installation folder:
$$(ProgramFiles)/MySQL/MySQL Server (8.1|8.0|5.7)/)
You can set these variables in the .env or .conf files (recommended), in
the qmake file (or wherever you want), or as environment variables.
These variables are set after the auto-configuration is done:
- TINY_VCPKG_INCLUDE - path to vcpkg include folder
(vcpkg/installed/<triplet>/include/)
- TINY_MYSQL_INCLUDE - path to the MySQL include folder (MySQL Server
8.1/include/)
- TINY_MYSQL_LIB - path to the MySQL lib folder (MySQL Server
8.1/include/)
The TINY_MYSQL_INCLUDE and TINY_MYSQL_LIB are only set on win32 except
mingw.
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