diff --git a/src/Command/Select.php b/src/Command/Select.php index de1353b7..4687d484 100644 --- a/src/Command/Select.php +++ b/src/Command/Select.php @@ -304,6 +304,20 @@ public function rightJoin(string $table, string $alias, $specification): self return $this; } + /** + * @see SqlSelect::fullJoin() + * + * @param string $table The joined table name + * @param string $alias The joined table alias + * @param On|Predicate|Predicate\Set|array|string|Literal|Identifier|null $specification + * @return $this Fluent interface + */ + public function fullJoin(string $table, string $alias, $specification = null): self + { + $this->sqlStatement->fullJoin($table, $alias, $specification); + return $this; + } + /** * @see SqlSelect::naturalJoin() * @@ -318,6 +332,20 @@ public function naturalJoin(string $table, string $alias, $specification = null) return $this; } + /** + * @see SqlSelect::naturalInnerJoin() + * + * @param string $table The joined table name + * @param string $alias The joined table alias + * @param On|Predicate|Predicate\Set|array|string|Literal|Identifier|null $specification + * @return $this Fluent interface + */ + public function naturalInnerJoin(string $table, string $alias, $specification = null): self + { + $this->sqlStatement->naturalInnerJoin($table, $alias, $specification); + return $this; + } + /** * @see SqlSelect::naturalLeftJoin() * @@ -346,6 +374,20 @@ public function naturalRightJoin(string $table, string $alias, $specification = return $this; } + /** + * @see SqlSelect::naturalFullJoin() + * + * @param string $table The joined table name + * @param string $alias The joined table alias + * @param On|Predicate|Predicate\Set|array|string|Literal|Identifier|null $specification + * @return $this Fluent interface + */ + public function naturalFullJoin(string $table, string $alias, $specification = null): self + { + $this->sqlStatement->naturalFullJoin($table, $alias, $specification); + return $this; + } + /** * @see SqlSelect::crossJoin() * @@ -361,16 +403,16 @@ public function crossJoin(string $table, string $alias, $specification = null): } /** - * @see SqlSelect::straightJoin() + * @see SqlSelect::unionJoin() * * @param string $table The joined table name * @param string $alias The joined table alias * @param On|Predicate|Predicate\Set|array|string|Literal|Identifier|null $specification * @return $this Fluent interface */ - public function straightJoin(string $table, string $alias, $specification = null): self + public function unionJoin(string $table, string $alias, $specification = null): self { - $this->sqlStatement->straightJoin($table, $alias, $specification); + $this->sqlStatement->unionJoin($table, $alias, $specification); return $this; } diff --git a/src/Sql.php b/src/Sql.php index ec7ce697..58318dbe 100644 --- a/src/Sql.php +++ b/src/Sql.php @@ -91,26 +91,32 @@ class Sql * Join clause types */ public const JOIN_AUTO = ''; - public const JOIN_INNER = 'INNER'; public const JOIN_CROSS = 'CROSS'; + public const JOIN_UNION = 'UNION'; + public const JOIN_INNER = 'INNER'; public const JOIN_LEFT = 'LEFT'; public const JOIN_RIGHT = 'RIGHT'; - public const JOIN_STRAIGHT = 'STRAIGHT'; + public const JOIN_FULL = 'FULL'; public const JOIN_NATURAL = 'NATURAL'; + public const JOIN_NATURAL_INNER = 'NATURAL INNER'; public const JOIN_NATURAL_LEFT = 'NATURAL LEFT'; public const JOIN_NATURAL_RIGHT = 'NATURAL RIGHT'; + public const JOIN_NATURAL_FULL = 'NATURAL_FULL'; public const USING = 'USING'; public const JOIN_TYPES = [ self::JOIN_AUTO => self::JOIN_AUTO, - self::JOIN_INNER => self::JOIN_INNER, self::JOIN_CROSS => self::JOIN_CROSS, + self::JOIN_UNION => self::JOIN_UNION, + self::JOIN_INNER => self::JOIN_INNER, self::JOIN_LEFT => self::JOIN_LEFT, self::JOIN_RIGHT => self::JOIN_RIGHT, - self::JOIN_STRAIGHT => self::JOIN_STRAIGHT, + self::JOIN_FULL => self::JOIN_FULL, self::JOIN_NATURAL => self::JOIN_NATURAL, + self::JOIN_NATURAL_INNER => self::JOIN_NATURAL_INNER, self::JOIN_NATURAL_LEFT => self::JOIN_NATURAL_LEFT, self::JOIN_NATURAL_RIGHT => self::JOIN_NATURAL_RIGHT, + self::JOIN_NATURAL_FULL => self::JOIN_NATURAL_FULL, ]; /* diff --git a/src/Sql/Statement/Select.php b/src/Sql/Statement/Select.php index d98f6059..2508f8b5 100644 --- a/src/Sql/Statement/Select.php +++ b/src/Sql/Statement/Select.php @@ -631,7 +631,7 @@ public function innerJoin(string $table, string $alias, $specification = null): } /** - * Add a LEFT JOIN clause + * Add a LEFT [OUTER] JOIN clause * * @param string $table The joined table name * @param string $alias The joined table alias @@ -646,7 +646,7 @@ public function leftJoin(string $table, string $alias, $specification = null): s } /** - * Add a RIGHT JOIN clause + * Add a RIGHT [OUTER] JOIN clause * * @param string $table The joined table name * @param string $alias The joined table alias @@ -660,6 +660,21 @@ public function rightJoin(string $table, string $alias, $specification = null): ); } + /** + * Add a FULL [OUTER] JOIN clause + * + * @param string $table The joined table name + * @param string $alias The joined table alias + * @param On|Predicate|Predicate\Set|array|string|Literal|Identifier|null $specification + * @return $this Fluent interface + */ + public function fullJoin(string $table, string $alias, $specification = null): self + { + return $this->addJoin( + new Join(Sql::JOIN_FULL, $table, $alias, $specification) + ); + } + /** * Add a NATURAL JOIN clause * @@ -676,7 +691,22 @@ public function naturalJoin(string $table, string $alias, $specification = null) } /** - * Add a NATURAL LEFT JOIN clause + * Add a NATURAL INNER JOIN clause + * + * @param string $table The joined table name + * @param string $alias The joined table alias + * @param On|Predicate|Predicate\Set|array|string|Literal|Identifier|null $specification + * @return $this Fluent interface + */ + public function naturalInnerJoin(string $table, string $alias, $specification = null): self + { + return $this->addJoin( + new Join(Sql::JOIN_NATURAL_INNER, $table, $alias, $specification) + ); + } + + /** + * Add a NATURAL LEFT [OUTER]JOIN clause * * @param string $table The joined table name * @param string $alias The joined table alias @@ -691,7 +721,7 @@ public function naturalLeftJoin(string $table, string $alias, $specification = n } /** - * Add a NATURAL RIGHT JOIN clause + * Add a NATURAL RIGHT [OUTER] JOIN clause * * @param string $table The joined table name * @param string $alias The joined table alias @@ -705,6 +735,21 @@ public function naturalRightJoin(string $table, string $alias, $specification = ); } + /** + * Add a NATURAL FULL [OUTER] JOIN clause + * + * @param string $table The joined table name + * @param string $alias The joined table alias + * @param On|Predicate|Predicate\Set|array|string|Literal|Identifier|null $specification + * @return $this Fluent interface + */ + public function naturalFullJoin(string $table, string $alias, $specification = null): self + { + return $this->addJoin( + new Join(Sql::JOIN_NATURAL_FULL, $table, $alias, $specification) + ); + } + /** * Add a CROSS JOIN clause * @@ -721,17 +766,17 @@ public function crossJoin(string $table, string $alias, $specification = null): } /** - * Add a STRAIGHT JOIN clause + * Add a UNION JOIN clause * * @param string $table The joined table name * @param string $alias The joined table alias * @param On|Predicate|Predicate\Set|array|string|Literal|Identifier|null $specification * @return $this Fluent interface */ - public function straightJoin(string $table, string $alias, $specification = null): self + public function unionJoin(string $table, string $alias, $specification = null): self { return $this->addJoin( - new Join(Sql::JOIN_STRAIGHT, $table, $alias, $specification) + new Join(Sql::JOIN_UNION, $table, $alias, $specification) ); } diff --git a/test/Command/SelectTest.php b/test/Command/SelectTest.php index 1b6c9d9a..9b506ae7 100644 --- a/test/Command/SelectTest.php +++ b/test/Command/SelectTest.php @@ -385,11 +385,14 @@ public function provideJoinOptions(): array ['crossJoin', Sql::JOIN_CROSS], ['innerJoin', Sql::JOIN_INNER], ['leftJoin', Sql::JOIN_LEFT], + ['rightJoin', Sql::JOIN_RIGHT], + ['fullJoin', Sql::JOIN_FULL], ['naturalJoin', Sql::JOIN_NATURAL], + ['naturalInnerJoin', Sql::JOIN_NATURAL_INNER], ['naturalLeftJoin', Sql::JOIN_NATURAL_LEFT], ['naturalRightJoin', Sql::JOIN_NATURAL_RIGHT], - ['rightJoin', Sql::JOIN_RIGHT], - ['straightjoin', Sql::JOIN_STRAIGHT], + ['naturalfullJoin', Sql::JOIN_NATURAL_FULL], + ['unionjoin', Sql::JOIN_UNION], ]; }