Commit Graph

174 Commits

Author SHA1 Message Date
silverqx dd62ff3de6 tom removed local variable 2022-11-30 21:24:08 +01:00
silverqx 68a94e819d tom added migrate:uninstall command
It drops the migration database repository with an optional reset.

 - updated zsh and bash completion scripts and integrate stubs
 - it also supports pretending and confirmable for production env.
2022-11-30 21:24:08 +01:00
silverqx 48dfba4bf8 tom bugfix parser for Concerns::Confirmable 2022-11-30 21:24:08 +01:00
silverqx 4018d472b1 whitespaces 2022-11-30 21:24:08 +01:00
silverqx 5bfcb30768 whitespaces 2022-11-30 21:24:07 +01:00
silverqx c1ef720a0f tom fixtypo 2022-11-30 21:24:07 +01:00
silverqx 2e16a475a1 tom added reserve 2022-11-30 15:47:50 +01:00
silverqx 038affcd6e tom moved guessPathForMakeByPwd to MakeCommenad
The guessPathForMakeByPwd() is not needed in the TomUtils, so moved out
to the MakeCommand base class.
2022-11-29 17:39:47 +01:00
silverqx 99f31e861c tom added support for hidden options 🤓
- also added reserve() for QString and lists
 - added note about m_options to application.cpp
 - fixtypo and enhanced some comments
2022-11-29 17:25:59 +01:00
silverqx dda396f667 bugfix Linux builds 2022-11-26 10:58:00 +01:00
silverqx 7f290b1f85 tom enhanced detection of paths for make: commands
The make:migration/seeder/model commands try to guess a path based
on the pwd and the defaultPath (can be relative or absolute; it can be
migrations, seeders, or models default path).

If the defaultPath is relative and the pwd is somewhere inside this
defaultPath, then it appends the rest of the path from the defaultPath
to the pwd, eg. the defaultPath = "aa/bb/cc/dd" and
the pwd = "E:/<some path>/aa/bb", then the guessed result path will be
"E:/<some path>/aa/bb/cc/dd", the "cc/dd" was appended.

This is the prime case how the intelligent logic can corrupt a nice
code, many people hate this type of logic, but whatever, it works
great, the logic is outsourced to the tom utils class, so it's not so
bad. 😵‍💫🙃
2022-11-25 21:05:16 +01:00
silverqx 28642035b2 used TMPL_ONE constant 2022-11-19 09:16:03 +01:00
silverqx 77e581f467 bugfix std::convertible_to
- abandoned cont Xyz & in std::convertible_to<>
 - made cout/wcout parameter const in the Terminal::hasColorSupport()
2022-11-13 16:59:34 +01:00
silverqx 6b6b192a82 used QLatin1Char everywhere
Except short parameters for tom because it would make code formatting
and code look much worse. 🫤
2022-11-12 03:19:09 +01:00
silverqx 7107f4340f fixed clang-tidy warnings 2022-11-07 12:32:10 +01:00
silverqx b277a2ffbe finished refactor to Orm::SqlQuery
Changed the DatabaseConnection::insert()/statement() return value to
the Orm::SqlQuery, after this lot of code had to be updated
to the SqlQuery.

 - updated also tests for BuildsQueries each/chunk/...
2022-11-07 11:17:19 +01:00
silverqx 13c457c359 added inline and noexcept to all CRTP static casts 2022-11-06 15:02:32 +01:00
silverqx ce45f247e0 added missing config.hpp include
Added everywhere, where macros from the config.hpp are used.
2022-11-06 14:40:20 +01:00
silverqx e6426ba4da fixed clang-tidy warnings for Qt5 2022-10-28 07:29:36 +02:00
silverqx 1ded27bbc8 QDateTime overhaul 🤯🤐🙃
Fixed buggy behavior of QDateTime values during SELECT, INSERT, and
UPDATE queries for all supported QtSql drivers. Behavior is fixed if
querying the database using Orm::QueryBuilder or TinyBuilder/Model.
Can't be fixed if using raw queries using the QSqlQuery because I don't
have any control over this code.

Every QtSql driver behaves differently in how it works with
the QDateTime and datetime-related database types. It doesn't have only
one problem, it has various kinds of problems, eg. it returns all
QDateTime objects in the local time zone. All issues are summarized
in NOTES.TXT under "QDateTime and database date/time types:"
section.

This buggy behavior can be fixed or corrected using a new "qt_timezone"
database connection configuration option. It accepts the time zone value
in various formats (QTimeZone, Qt::TimeSpec, int number as an offset
from UTC, QString eg. +02:00, Europe/Prague or Orm::QtTimeZoneConfig).
This "qt_timezone" value affects how the  QueryBuilder and TinyBuilder
send and receives datetime-related types to/from database. It should be
set to the same time zone value as the "timezone" connection
configuration option.

During the INSERT and UPDATE statements, it CONVERTS QDateTime's
time zone to the qt_timezone value before the statement is sent
to the database.
And during the SELECT statements it SETS QDateTime's time zone value
after the values are obtained from the database.

So if you set the "timezone" to UTC and "qt_timezone" to eg. Qt::UTC or
QTimeZone::utc(), then QDateTime values will have set the correct
time zone, in this case, the time zone will be UTC.

For the SQLite database was also added the "return_qdatetime" connection
configuration option which default value is true. By default,
the QSQLITE driver returns datetime values as QString.
The "return_qdatetime" controls this behavior and if is set to true then
the QDateTime will be returned instead.

TinyORM QueryBuilder returns the Orm::SqlQuery instead of QSqlQuery
from methods for which the QDateTime's time zone should be corrected.
That are eg. the select(), selectOne(), unprepared(), or chunk(),
chunkById(), each(), eachById(), ...

Orm::SqlQuery is a simple wrapper around the QSqlQuery whose
responsibility is only to fix a QDateTime's time zone.

Also unified the QDate behavior across all QtSql drivers.

 - added a new migration for the datetime table for testing QDateTime
   and datetime-related database types
 - added new Datetime model
 - added functional tests for testing datetime-related queries
   - testing QDateTime for all supported drivers
   - testing with different time zones, UTC, +02:00
   - testing QDate for all supported drivers
 - added two new connection configuration options "qt_timezone" and
   "return_qdatetime" which is for the SQLite database only
 - added returnQDateTime()/setReturnQDateTime() getter/setter
   to the SQLiteConnection class
 - added getQtTimeZone()/setQtTimeZone()/isConvertingTimeZone()
   to the DatabaseConnection class
 - tests, fixed all QDateTime instances, changed time zone to UTC, so
   auto tests are now UTC, they force also MySQL and PostgreSQL server
   time zone session variable to UTC

Others:

 - StringUtils moved from orm/tiny/utils/ to the orm/utils/ folder
   to the ::Orm::Utils namespace
 - enhanced all database connection constructors, used rvalue references
 - added delegated DatabaseConnection() constructor
   for SQLiteConnection() because of m_returnQDateTime
2022-10-27 14:30:00 +02:00
silverqx 1849848481 fixed clazy warning 2022-09-23 17:06:01 +02:00
silverqx 4b2a26b0d3 upgraded to clang tidy 15
Fixed warnings for bugprone-unchecked-optional-access and
misc-const-correctness new checks.
2022-09-23 16:00:24 +02:00
silverqx 36c6ddea8b enhanced StringUtils::isNumber()
Added the allowPlusMinus parameter.
2022-09-19 14:32:27 +02:00
silverqx ba1dd48ee7 updated todo task 2022-08-21 18:33:30 +02:00
silverqx 72f864d69f fixtypo 2022-08-19 13:40:22 +02:00
silverqx cc9327a04e avoid ambiguous call 2022-08-17 15:14:47 +02:00
silverqx 89a087b743 used constFirst or first instead of [0] 2022-08-17 15:14:12 +02:00
silverqx e6566fc474 used constFirst or front instead of at(0) 2022-08-17 13:45:29 +02:00
silverqx eb517147fe renamed resolver to connectionResolver 2022-08-17 09:59:55 +02:00
silverqx 63b8a5884e tom bugfix using a default connection
After support for multiple connections for the --database= option was
added a default connection have stopped work.

Reworked support for multiple connections, the loop was moved to the
usingConnections() methods instead of foreach loop inside commands.

 - also enahnced handling of exit codes for commands which execute
   another commands
2022-08-17 09:29:26 +02:00
silverqx 8869206fa6 tom removed unused m_resolver data member 2022-08-16 21:30:24 +02:00
silverqx 34b2267e45 tom throw if no conn. configuration registered 2022-08-16 21:21:19 +02:00
silverqx 20af1a9186 modified inline comment 2022-08-16 21:17:19 +02:00
silverqx 79876168ef fixtypo 2022-08-16 21:16:07 +02:00
silverqx 2c987ead90 bugfix tom count configs. instead of connections
Count registered connection configurations instead of opened
connections. 🫤

 - renamed connectionsSize to DB/DM::openedConnectionsSize()
 - added DB/DM::originalConfigsSize()
2022-08-16 21:15:51 +02:00
silverqx 1ec9543920 moved version constant to Orm::Constants 2022-08-12 11:54:59 +02:00
silverqx ea16c25ecb fixed move on return 2022-08-04 13:02:50 +02:00
silverqx 05be7c611a move all using into TINYORM_COMMON_NAMESPACE 2022-08-02 11:03:29 +02:00
silverqx c2f94d30d0 fixed vstudio analyzer warnings 2022-07-16 21:19:20 +02:00
silverqx a6b52ed151 fixed vstudio analyzer warnings 2022-07-16 19:39:14 +02:00
silverqx 3fff6817d6 tom make:migrate connection name in quiet mode 2022-07-12 11:23:20 +02:00
silverqx 9162c5a53d used shared_ptr everywhere
Get rid of the QSharedPointer and use the std::shared_ptr everywhere.
2022-07-10 17:36:53 +02:00
silverqx da9e7178d8 tom fixed obtaining the parent path 2022-07-10 11:46:12 +02:00
silverqx c47b2819eb tom revisited short options
- used QChar to pass short options
 - updated zsh shell completion
2022-07-10 11:15:11 +02:00
silverqx 1f843372d3 tom added force option to make commands
Allow to overwrite already existing migration, model, seeder.
2022-07-10 10:40:48 +02:00
silverqx a0b743f234 tom make:seeder removed unneeded getStub method 2022-07-09 13:44:10 +02:00
silverqx e3ef403fee fixtypo unified Classname vs ClassName in code 2022-07-09 09:41:28 +02:00
silverqx f5f47eb87c tom make:model added --seeder/--migration options
The make:model can also generate seeder and migration in one short using
the --seeder and --migration options.
2022-07-09 09:38:44 +02:00
silverqx 9893d0067f tom make:migration updated options descriptions 2022-07-09 09:37:39 +02:00
silverqx 4c0121dbde tom make:model updated help pivot-inverse 2022-07-09 08:10:57 +02:00