diff --git a/src/Upsert.php b/src/Upsert.php index 72a3d0d..7869b2f 100644 --- a/src/Upsert.php +++ b/src/Upsert.php @@ -8,6 +8,7 @@ use Doctrine\DBAL\Connection; use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractMySQLPlatform; +use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Platforms\SqlitePlatform; use RuntimeException; @@ -121,22 +122,24 @@ protected function buildQuery(string $identifiers, string $columns, string $valu return match (true) { $platform instanceof PostgreSQLPlatform => <<table}" ({$columns}) -VALUES ({$values}) -ON CONFLICT ({$identifiers}) DO UPDATE SET {$updates} -POSTGRESQL + INSERT INTO "{$this->table}" ({$columns}) + VALUES ({$values}) + ON CONFLICT ({$identifiers}) DO UPDATE SET {$updates} + POSTGRESQL , - $platform instanceof AbstractMySQLPlatform => <<table} ({$columns}) -VALUES ({$values}) -ON DUPLICATE KEY UPDATE {$updates} -MYSQL - ,$platform instanceof SqlitePlatform => <<table} ({$columns}) -VALUES ({$values}) -ON CONFLICT({$identifiers}) DO UPDATE SET {$updates} -SQLITE - ,default => throw new RuntimeException( + $platform instanceof AbstractMySQLPlatform || $platform instanceof MySqlPlatform => <<table} ({$columns}) + VALUES ({$values}) + ON DUPLICATE KEY UPDATE {$updates} + MYSQL + , + $platform instanceof SqlitePlatform => <<table} ({$columns}) + VALUES ({$values}) + ON CONFLICT({$identifiers}) DO UPDATE SET {$updates} + SQLITE + , + default => throw new RuntimeException( sprintf('The database platform %s is not supported!', $platform::class), 1_603_199_935 )