Commit Graph

95 Commits

Author SHA1 Message Date
silverqx db5aa004a1 all exceptions moved to own folder and namespace 2021-08-05 21:13:23 +02:00
silverqx dd55222a57 all proxy methods extracted to base classes
All proxy methods on TinyBuilder, Model and Relation moved to their own
base classes.
This change makes the classes code in headers more clear.
2021-08-05 13:51:42 +02:00
silverqx 9d8304ae32 changed method position 2021-08-03 14:21:59 +02:00
silverqx 7ca8910cc4 added querying relationship existence/absence
- support for querying nested relations existence/absence
 - added tests for all possible overloads 😲, 28 unit tests and 14
   functional tests
 - added has() related proxies to the Model and Relation
 - added documentation
 - gcc and clang specific fixes

others:

 - used clazy exclude comments instead of suppressing warnings in IDE
2021-08-03 09:31:31 +02:00
silverqx 1e40fa3e61 failed to add explain()
Qt sql driver does not support to call EXPLAIN as a prepared statement.
2021-07-19 10:19:53 +02:00
silverqx d1044e37bc added subquery support for order by clause 2021-07-18 20:49:56 +02:00
silverqx 4b4f34fbdc added support for subqueries in the select clause 2021-07-18 13:38:53 +02:00
silverqx 1d10afa6c0 added/replaced QChar constants for most used chars 2021-07-17 14:44:27 +02:00
silverqx 5d4391900a replaced = strings with EQ constant 2021-07-17 14:44:27 +02:00
silverqx 7d1f03021b added global constants for most used strings 2021-07-17 14:41:28 +02:00
silverqx 40b639c458 subquery support for where() columns 🔥🚀
where() column can take lambda expression or QueryBuilder &
for subqueries.

 - added proxy methods
 - added unit tests
 - proxy methods tested manually
2021-07-15 16:44:23 +02:00
silverqx ef1660dd6d subquery support for where() values 🔥🚀
where() values can take labmbda expression or QueryBuilder &
for subqueries.

 - added proxy methods
 - added unit tests
2021-07-15 08:24:46 +02:00
silverqx b1f68ae140 added const to aggregate methods 2021-07-13 17:01:08 +02:00
silverqx a4fe443541 added pluck()
Two overloads, simple pluck(column) to get values from the given column
and pluck<T>(column, key) which returns std::map<T, QVariant> values
of the given column keyed by the given key.

 - added docs
 - added tests
 - manually tested all proxies
2021-07-13 14:28:41 +02:00
silverqx 867a5f6587 added missing raw methods
or/whereRaw(), groupByRaw(), or/havingRaw(), orderByRaw().

 - added docs
 - tested manually in Playground
2021-07-06 18:28:58 +02:00
silverqx a1d9183af1 added new joinSub() overload
With the callback for join on clause.
2021-07-06 10:57:02 +02:00
silverqx bedd67120a removed all expressions todo tasks 🙌
Expressions finished.
2021-07-06 08:26:52 +02:00
silverqx 1aa0ef9cae added proxies for Aggregates
- all new proxies tested manually in Playground
2021-07-05 20:10:51 +02:00
silverqx c1c37cdf84 column expressions for having and orderBy
having() and orderBy() related methods now take column expressions.

 - added all proxies
 - all new code tested manually in the TinyOrmPlayground
2021-07-05 14:40:09 +02:00
silverqx 7298d72623 groupBy column expressions and new overload
groupBy() methods now take column expressions.

 - added all proxies
 - added new perfectly forwarded groupBy(&&...args) overload
 - all new code tested manually in the TinyOrmPlayground
2021-07-05 11:57:12 +02:00
silverqx 5626788eb6 renamed FromClause concept to SubQuery
Forgotten uncommitted code ☹.
2021-07-04 17:08:42 +02:00
silverqx 45f3779d89 added selectRaw() and selectSub()
- also added proxy methods
 - added tests
 - renamed FromClause concept to SubQuery
2021-07-03 17:24:06 +02:00
silverqx 452cfe8669 select can take expressions
All the select() related methods can take expressions as column names.

It has an impact on these methods: select, addSelect, get, all, first,
value, firstOrNew, firstOrFailed, find, findOrNew, findOrFailed,
findMany, firstWhere and also pivot columns for the BelongsToMany
relation.

 - expressions tests for get, first, value and find, select, addSelect
 - bugfix value expression in where and having
 - manually tested all the changed methods which don't have auto tests
   with normal and expression values, one by one
 - made overridden methods in BelongsToMany virtual in Relation class
2021-07-02 15:57:51 +02:00
silverqx ef7f84228d added/updated join proxy methods
- added joinSub() proxies
 - updated all join() methods to take expression for table parameter
2021-06-29 19:16:45 +02:00
silverqx 6c0423d6a8 reordered whereNull() methods
Vector<Column> overloads first.
2021-06-29 14:35:32 +02:00
silverqx 235a7dbf31 all where methods can take expression for column
All column parameters in where methods can take expressions, it's
amazing how it progresses and how everything fits together. 🤔🔥

 - added unit tests to test expressions for where methods
2021-06-29 14:31:30 +02:00
silverqx 684234a6d2 reordered whereNull() proxy methods 2021-06-29 14:24:16 +02:00
silverqx d28338c534 removed todo task 2021-06-19 14:39:50 +02:00
silverqx 12eee06024 added toSql and getBindings proxy methods 2021-06-19 14:39:01 +02:00
silverqx 23e0a35a17 added expressions and subquery in from clause
Added fromRaw() and fromSub(), I didn't add them to the TinyBuilder,
Model and Relation on purpose.

 - added tests for fromRaw() and fromSub()
 - fromSub() also supports cross database queries, works on MySQL, but
   I also tried on postgres and it didn't work
 - tiny expressions are correctly handled in from clause now
2021-06-18 18:05:20 +02:00
silverqx 39ec79e6ab updated todo tasks 2021-06-16 20:24:37 +02:00
silverqx 834901c742 removed unused type AssignmentList 2021-06-16 18:37:46 +02:00
silverqx f7442f5c4d added pragma once to every header file 2021-06-16 14:37:16 +02:00
silverqx cc8fd5edaa used QStringLiteral where can save instantiation
Almost everywhere.
2021-06-15 19:38:25 +02:00
silverqx c0e5dcb582 renamed pivotAttributes to pivotValues
Also removed/updated todos.
2021-06-15 17:07:52 +02:00
silverqx 944c1e4588 added new methods to BelongsToMany relation
Added find, findOrNew, findOrFail, findMany, first, firstOrNew,
firstOrCreate, firstOrFail, firstWhere, firstWhereEq and updateOrCreate.

 - proxy methods to the TinyBuilder on the Relation class now return
   const Relation & instead of TinyBuilder &
 - remove a primary key from attributes used in where() for selecting
   row in firstOrCreate()/firstOrNew() methods
2021-06-15 08:53:04 +02:00
silverqx be6f98ee7a added new methods to HasOneOrMany relations
- added findOrNew, firstOrNew, firstOrCreate and updateOrCreate
 - added findMany to to builders and only to HasMany relation
 - added new whereKey/whereNotKey overloads
2021-06-11 09:27:41 +02:00
silverqx f82c09d099 copy vs move optimizations on simple find() 2021-06-09 15:22:48 +02:00
silverqx f4ed5eeae3 added missing insert proxy methods 2021-06-07 18:51:58 +02:00
silverqx 3c14bc9786 added missing with() tiny builder's overloads 2021-06-07 15:00:46 +02:00
silverqx bb5db0c368 added missing methods on query builders
Added missing distinct overloads and methods for Pessimistic locking.
2021-06-07 12:12:33 +02:00
silverqx 7f0c824e77 reordered methods in query builders 2021-06-07 11:06:20 +02:00
silverqx 778a225b1f added PostgreSQL support 🔥🚀
- also all tests pass, problem was only with bool values and truncate
   statement ( can't be send as prepared statement )
 - updated migration and seeds, added PostgreSQL connection
 - bugfix in migration script ?? vs ?:
 - added DatabaseConnection::unprepared()
2021-06-02 15:59:04 +02:00
silverqx 84e456060b added support for table prefixes
- also added tests
2021-05-28 18:23:05 +02:00
silverqx 17b02be739 cleaned todo tasks 2021-05-27 18:54:17 +02:00
silverqx 8499a177ba removed custom code for qMedia project
Removed support for json column in q_media_test_orm.torrents table.
2021-05-27 14:55:29 +02:00
silverqx f96b6d8809 added Model::withOnly and tests 2021-05-25 10:46:06 +02:00
silverqx 1a1951f1da removed todos 2021-05-22 15:26:19 +02:00
silverqx 432d203b98 used std::ranges when available 2021-05-22 08:26:45 +02:00
silverqx 24ed161663 added tests for Model::with
If eager loading BelongsToMany relation, then columns for the related
table have to be qualified.
2021-05-20 15:22:31 +02:00