Skip to content

Commit

Permalink
Support Laravel's new toRawSql()
Browse files Browse the repository at this point in the history
  • Loading branch information
staudenmeir committed Jul 12, 2023
1 parent 588c59b commit 3c1d62d
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Query/Traits/BuildsExpressionQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,20 @@ protected function getQueryGrammar(Connection $connection)
{
$driver = $connection->getDriverName();

switch ($driver) {
case 'mysql':
return new MySqlGrammar();
case 'pgsql':
return new PostgresGrammar();
case 'sqlite':
return new SQLiteGrammar();
case 'sqlsrv':
return new SqlServerGrammar();
$grammar = match ($driver) {
'mysql' => new MySqlGrammar(),
'pgsql' => new PostgresGrammar(),
'sqlite' => new SQLiteGrammar(),
'sqlsrv' => new SqlServerGrammar(),
default => throw new RuntimeException('This database is not supported.'), // @codeCoverageIgnore
};

// TODO[L11]
if (method_exists($grammar, 'setConnection')) {
$grammar->setConnection($connection);
}

throw new RuntimeException('This database is not supported.'); // @codeCoverageIgnore
return $grammar;
}

/**
Expand Down

0 comments on commit 3c1d62d

Please sign in to comment.