Skip to content

Commit 0f45bd8

Browse files
committed
Add CROSS JOIN clause
1 parent ebdf2f0 commit 0f45bd8

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/Manipulation/Traits/Join.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,18 @@ public function innerJoinUsing(Closure | string $table, Closure | string ...$col
157157
return $this->setJoin($table, 'INNER', 'USING', $columns);
158158
}
159159

160+
/**
161+
* Sets the JOIN clause as "CROSS JOIN $table".
162+
*
163+
* @param Closure|string $table Table factor
164+
*
165+
* @return static
166+
*/
167+
public function crossJoin(Closure | string $table) : static
168+
{
169+
return $this->setJoin($table, 'CROSS');
170+
}
171+
160172
/**
161173
* Sets the JOIN clause as "CROSS JOIN $table ON $conditional".
162174
*

tests/Manipulation/Traits/JoinTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@ public function testInnerJoinUsing() : void
157157
self::assertSame(' INNER JOIN `t1` USING (`user_id`)', $this->statement->renderJoin());
158158
}
159159

160+
public function testCrossJoin() : void
161+
{
162+
$this->statement->crossJoin('t1');
163+
self::assertSame(' CROSS JOIN `t1`', $this->statement->renderJoin());
164+
}
165+
160166
public function testCrossJoinOn() : void
161167
{
162168
$this->statement->crossJoinOn('t1', static fn () => 't1.id = t2.id');

0 commit comments

Comments
 (0)