mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-12 20:38:56 -05:00
added crossJoin overload
- also added docs
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user