diff --git a/src/Fluent/Connection.php b/src/Fluent/Connection.php index 7c6b30e..d9f5176 100644 --- a/src/Fluent/Connection.php +++ b/src/Fluent/Connection.php @@ -403,7 +403,7 @@ public function merge(?string $into = NULL, ?string $alias = NULL): Query /** - * @param array|string|Query|Db\Sql $dataSource values, table or query + * @param string|Query|Db\Sql $dataSource values, table or query * @param string|Complex|Db\Sql|NULL $onCondition * @return QueryExecute * @throws Exceptions\QueryException diff --git a/src/Fluent/Query.php b/src/Fluent/Query.php index 04f722b..32cc79e 100644 --- a/src/Fluent/Query.php +++ b/src/Fluent/Query.php @@ -56,6 +56,8 @@ class Query implements Sql public const MERGE_USING_DATA_SOURCE = 'using-data-source'; public const MERGE_USING_ALIAS = 'using-alias'; public const MERGE_WHEN = 'when'; + public const MERGE_WHEN_MATCHED = 'when-matched'; + public const MERGE_WHEN_NOT_MATCHED = 'when-not-matched'; public const WITH_QUERIES = 'queries'; public const WITH_QUERIES_SUFFIX = 'queries-suffix'; @@ -672,7 +674,7 @@ public function merge(?string $into = NULL, ?string $alias = NULL): self /** - * @param array|string|self|Db\Sql $dataSource values, table or query + * @param string|self|Db\Sql $dataSource values, table or query * @param string|Complex|Db\Sql|NULL $onCondition * @return static * @throws Exceptions\QueryException @@ -682,6 +684,7 @@ public function using($dataSource, ?string $alias = NULL, $onCondition = NULL): $this->resetQuery(); $this->queryType = self::QUERY_MERGE; $this->params[self::MERGE_USING_DATA_SOURCE] = $dataSource; + $this->params[self::MERGE_USING_ALIAS] = $alias; return $this; } @@ -693,6 +696,9 @@ public function using($dataSource, ?string $alias = NULL, $onCondition = NULL): */ public function whenMatched(string $then, $onCondition = NULL): self { + $this->resetQuery(); + $this->params[self::MERGE_WHEN][] = [self::MERGE_WHEN_MATCHED, $then, $onCondition]; + return $this; } @@ -703,6 +709,9 @@ public function whenMatched(string $then, $onCondition = NULL): self */ public function whenNotMatched(string $then, $onCondition = NULL): self { + $this->resetQuery(); + $this->params[self::MERGE_WHEN][] = [self::MERGE_WHEN_NOT_MATCHED, $then, $onCondition]; + return $this; } diff --git a/src/Fluent/Sql.php b/src/Fluent/Sql.php index 2167d84..e9a4e1d 100644 --- a/src/Fluent/Sql.php +++ b/src/Fluent/Sql.php @@ -211,7 +211,7 @@ function merge(?string $into = NULL, ?string $alias = NULL): Query; /** - * @param array|string|Query|Db\Sql $dataSource values, table or query + * @param string|Query|Db\Sql $dataSource values, table or query * @param string|Complex|Db\Sql|NULL $onCondition */ function using($dataSource, ?string $alias = NULL, $onCondition = NULL): Query;