added crossJoin overload

- also added docs
This commit is contained in:
silverqx
2022-07-12 15:36:41 +02:00
parent 35fa3158ef
commit bc35186e9e
2 changed files with 21 additions and 0 deletions
+8
View File
@@ -250,6 +250,14 @@ If you would like to perform a "left join" or "right join" instead of an "inner
->rightJoin("posts", "users.id", "=", "posts.user_id")
.get();
#### Cross Join Clause
You may use the `crossJoin` method to perform a "cross join". Cross joins generate a cartesian product between the first table and the joined table:
auto sizes = DB::table("sizes")
->crossJoin("colors")
.get();
#### Advanced Join Clauses
You may also specify more advanced join clauses. To get started, pass a lambda expression as the second argument to the `join` method. The lambda expression will receive a `Orm::Query::JoinClause` instance which allows you to specify constraints on the "join" clause:
+13
View File
@@ -238,6 +238,9 @@ namespace Orm::Query
template<JoinTable T>
inline Builder &
crossJoin(T &&table, const std::function<void(JoinClause &)> &callback);
/*! Add a "cross join" clause to the query. */
template<JoinTable T>
inline Builder &crossJoin(T &&table);
/*! Add a subquery join clause to the query. */
template<SubQuery T>
@@ -928,6 +931,16 @@ namespace Orm::Query
return join(table, callback, CROSS);
}
template<JoinTable T>
Builder &
Builder::crossJoin(T &&table)
{
// No need to call joinInternal() because no bindings
m_joins.append(newJoinClause(*this, CROSS, std::forward<T>(table)));
return *this;
}
template<SubQuery T>
Builder &
Builder::joinSub(T &&query, const QString &as, const QString &first,