Commit Graph

1229 Commits

Author SHA1 Message Date
silverqx b2e3f09227 added new constants
Because of the MariaDB.
2023-03-14 12:48:22 +01:00
silverqx 950ec618b2 bugfix removed extra constant 2023-03-14 12:48:21 +01:00
silverqx df29453e68 constants fixed order 2023-03-14 12:48:21 +01:00
silverqx 6afbd01b93 schema enhanced generated columns
- refactored PostgreSQL grammar for generated columns
 - unified nullable() on generated columns, now it behaves the same for
   all supported databases and also behaves the same as everywhere else
 - used an optional "generated always as" for all databases instead of
   only "as ()" because it better expresses what it means, "as ()" looks
   very similar like a column alias
 - temporarily disabled logic in MySQL::nullable() for MariaDB, I'm
   going to prepare and set up the MariaDB dev. env. to correctly
   support it, then I will finish it
 - added tests

Others:

 - tests for MySQL and PostgreSQL added tests to test multiple
   auto-increment starting values (startingValue() or from() alias)
2023-03-14 12:48:20 +01:00
silverqx a9d1e7aa07 schema bugfix fluent commands
The clang-tidy used after move warning was correct 🫤.
2023-03-14 12:48:20 +01:00
silverqx 538f0e34c7 schema whitespaces 2023-03-14 12:48:20 +01:00
silverqx 057a6f576a schema reordered modify methods 2023-03-14 12:48:19 +01:00
silverqx e816a5356e removed todo task 2023-03-14 12:48:19 +01:00
silverqx 500ab6b257 schema used modifier to set timestamp default
Used TinyORM modifiers to set a default value and for the MySQL also
"on update" value for the datetime and timestamp column types.

Previously, the SQL for a default value and for the "on update" was
generated right away, now, the ColumnDefinition instance is modified
and later in the SQL generation process will be this clauses generated.

 - updated tests, the order of the null value and default values were
   switched
2023-03-14 12:48:19 +01:00
silverqx a06091e07e schema compiling of auto-increment starting value
Compile auto-increment starting value as fluent command.
2023-03-14 12:48:18 +01:00
silverqx a138b2e1aa schema updated comment 2023-03-14 12:48:17 +01:00
silverqx bc867de028 bump version to TinyORM v0.28.2
- removed pointless and confusing methods on Model
2023-03-14 11:12:42 +01:00
silverqx 40c53ced94 removed pointless and confusing methods on Model
Removed Model::dump() and Model::dd() proxy methods, they are pointless
and are confusing.
2023-03-14 10:54:37 +01:00
silverqx 0d34243920 bump version to TinyORM v0.28.1
- bugfix dangling reference 😵‍💫😲🙃
2023-03-12 17:35:18 +01:00
silverqx 60bbaab033 bugfix dangling reference 😵‍💫😲🙃
The QueryGrammar instance was dangling reference after a connection was
removed and created again.
2023-03-12 15:05:10 +01:00
silverqx 051eb213e0 bump version to TinyORM v0.28.0 and tom v0.5.3
- refactored SchemaBuilder instantiation
 - added connection name to Exceptions::QueryError
 - tom added --pending option to migrate:status
 - tom added --batch=X option to migrate:rollback
 - docs added migrate --pending and --batch sections
 - schema added ability to add table comment
 - schema added ability to call comment() on SQLite
 - optimized eager loading when no keys to be loaded
 - dropped return value for connectEagerly()
 - allowed to pass QueryBuilder to whereExists
 - allowed to pass expression to pluck()
 - schema added datetimes and softDeletesDatetime
 - renamed to Blueprint::datetime/Tz()
 - schema added withoutForeignKeyConstraints()
 - added dropDatetimes() and dropSoftDeletesDatetime()
2023-02-22 14:43:01 +01:00
silverqx 564328f6f7 schema added drop aliased
Added dropDatetimes() and dropSoftDeletesDatetime().

 - updated docs
2023-02-21 13:38:28 +01:00
silverqx 66f278d180 schema added withoutForeignKeyConstraints()
Added shortcut method which disables foreign key constraints during the
execution of a callback.

 - updated docs
2023-02-21 12:54:25 +01:00
silverqx 307e899f07 renamed to Blueprint::datetime/Tz()
- also updated docs
2023-02-21 12:38:24 +01:00
silverqx 8447bb6d16 schema added datetimes and softDeletesDatetime
Added the datetimes() and softDeletesDatetime() shortcut methods
to the Blueprint.

 - updated docs
2023-02-21 12:32:25 +01:00
silverqx 59ee105524 renamed methods in BaseGrammar 2023-02-21 09:36:20 +01:00
silverqx 871bcffd09 allowed to pass expression to pluck()
- added unit tests
2023-02-21 09:21:54 +01:00
silverqx 5082afb81e removed useless includes 2023-02-20 17:17:39 +01:00
silverqx ea7bbb1e8d whitespaces 2023-02-20 17:16:49 +01:00
silverqx d128029384 added missing include 2023-02-20 17:16:41 +01:00
silverqx 362be240c6 allowed to pass QueryBuilder to whereExists
Refactored whereExists() to accept the std::shared_ptr<QueryBuilder> and
QueryBuilder &.

 - added unit and functional test
 - updated docs
 - updated all proxies
2023-02-20 16:50:48 +01:00
silverqx bb3a1139a5 dropped return value for connectEagerly() 2023-02-20 11:43:27 +01:00
silverqx ffb92bf832 optimized eager loading when no keys to be loaded
Avoided querying the database if the related keys are empty, avoided
WHERE IN () aka. where 0 = 1.
2023-02-20 11:30:48 +01:00
silverqx b3d561b760 updated comment 2023-02-19 19:36:57 +01:00
silverqx 004bcbe72f added todo task 2023-02-19 19:36:47 +01:00
silverqx 6007d5f3d4 schema added ability to add table comment
The table comment can be added for the MySQL and PostgreSQL databases.
The SQLite database doesn't support it.

 - added unit and functional tests
 - added docs
2023-02-19 18:27:38 +01:00
silverqx 110746670e added connection name to Exceptions::QueryError 2023-02-18 15:42:06 +01:00
silverqx d26e45b1e6 added noexcept to getters and made some inline 2023-02-18 15:41:48 +01:00
silverqx 53d8724a93 bugfix iterator const-ness 2023-02-18 09:12:04 +01:00
silverqx a562fb74c2 used set for guardable columns cache 2023-02-18 09:01:58 +01:00
silverqx 87d051e1b3 refactored SchemaBuilder instantiation
Made it pure virtual in the DatabaseConnection and instances are created
only in the derived Connection classes, used the same pattern like for
the SchemaGrammar or QueryGrammar.

So now the SchemaBuilder instance is saved in the DatabaseConnection
itself instead of the cache in the Schema as it was before.
2023-02-17 21:51:19 +01:00
silverqx b561b42e89 added todo task 2023-02-17 21:43:47 +01:00
silverqx 9a72519a76 added missing forward declaration 2023-02-16 11:38:49 +01:00
silverqx 7fc4191b31 schema moved duplicate code to base class
- only two compile methods, they had the same code for all databases
2023-02-15 19:24:02 +01:00
silverqx 3a4d9dd35d added reserve for ranges::move() 2023-02-15 16:19:55 +01:00
silverqx b7414f2720 made Processor abstract class
- also removed duplicate code, method moved to the base class
 - made derived processor classes final
2023-02-15 15:09:28 +01:00
silverqx f566c03b86 used .append() instead of QString.arg()
Enhanced joining algorithms.
2023-02-15 10:15:01 +01:00
silverqx 63e9fdc936 bugfix switched template arguments 😲🙃 2023-02-15 10:14:06 +01:00
silverqx b13728db08 refactored PostgreSQL search_path configuration
Changed from the 'schema' configuration option to the 'search_path',
the 'schema' config. option was dropped and currently throws exception
with a suggestion to use the 'search_path' instead.

The new 'search_path' config. option can be the QString or QStringList
and also supports to set an empty search_path using '' or empty QString
or QStringList.
This search_path config. option is correctly parsed and quoted.
Setting the search_path is initiated from the PostgresConnector
right after the database connection is established.

The PostgresSchemaBuilder is actively using the search_path during
practically all method calls (dropAllTables(), getColumnListing(),
hasTable(), ...). If the search_path is not defined then it queries
the database for the real search_path because the search_path can be
changed anytime and the search_path configuration option value can be
incorrect (out of sync).
It also works correctly with the empty search_path, in this case a fully
qualified table names are required. If the table name is not fully
qualified then the SearchPathEmptyError exception is thrown.
And it also works correctly with the "$user" PostgreSQL's variable, this
variable is resolved to the config["username"] during obtaining
the search_path from the database.

In the pretend mode it behaves little different, if pretending then
the 'search_path' is obtained from the connection configuration and
if the 'search_path' is not defined in the config. the 'public' will
be used as the default.

 - added many new unit and functional tests which are testing all the
   above described scenarios
   - added new functional test case tst_PostgreSQL_SchemaBuilder_f
   - added new functional test case tst_SchemaBuilder
   - added new tests for dropAllTable(), dropAllViews(), hasTable(),
     getColumnListing(), createDatabase(), dropDatabaseIfExists()
     for ALL supported databases
 - added new search_path constant
 - renamed env. variable to DB_PGSQL_SEARCHPATH (from DB_PGSQL_SCHEMA)
 - added new search_path and dont_drop configuration validations to
   check correct type (QString or QStringList)
 - added new 'schema' config. option validation
 - added new exception SearchPathEmptyError
 - started the TinyUtils::Databases refactor
2023-02-11 09:39:28 +01:00
silverqx 0248d9f9ea fixtypo 2023-02-10 19:26:00 +01:00
silverqx 47074e19a9 added trim, ltrim, rtrim to StringUtils 2023-02-10 17:25:34 +01:00
silverqx ede80ecfde used more qualified NS
- also used the EMPTY constant
2023-02-10 16:20:35 +01:00
silverqx 67d4b65870 whitespaces 2023-02-08 20:41:29 +01:00
silverqx a036e3d157 added IWYU pragma 2023-02-08 20:41:28 +01:00
silverqx 0205bfac9e added and used a new SQUOTE constant 2023-02-06 16:36:44 +01:00