Skip to content

Commit 504f893

Browse files
committed
Add Connection::getDriverTitle and move compileConnectionCount to the Schema Grammar
1 parent 2076d3b commit 504f893

16 files changed

+78
-36
lines changed

src/Illuminate/Database/Connection.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,6 +1347,16 @@ public function getDriverName()
13471347
return $this->getConfig('driver');
13481348
}
13491349

1350+
/**
1351+
* Get a human-readable name for the given connection driver.
1352+
*
1353+
* @return string
1354+
*/
1355+
public function getDriverTitle()
1356+
{
1357+
return $this->getDriverName();
1358+
}
1359+
13501360
/**
13511361
* Get the query grammar used by the connection.
13521362
*

src/Illuminate/Database/Console/DatabaseInspectionCommand.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,11 @@ abstract class DatabaseInspectionCommand extends Command
2020
* @param string $database
2121
* @return string
2222
*
23-
* @deprecated Use $connection->getName() instead.
23+
* @deprecated Use $connection->getDriverTitle() instead.
2424
*/
2525
protected function getConnectionName(ConnectionInterface $connection, $database)
2626
{
27-
return match (true) {
28-
$connection instanceof MariaDbConnection => 'MariaDB',
29-
$connection instanceof MySqlConnection && $connection->isMaria() => 'MariaDB',
30-
$connection instanceof MySqlConnection => 'MySQL',
31-
$connection instanceof PostgresConnection => 'PostgreSQL',
32-
$connection instanceof SQLiteConnection => 'SQLite',
33-
$connection instanceof SqlServerConnection => 'SQL Server',
34-
default => $database,
35-
};
27+
return $connection->getDriverTitle();
3628
}
3729

3830
/**

src/Illuminate/Database/Console/ShowCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function handle(ConnectionResolverInterface $connections)
4545
$data = [
4646
'platform' => [
4747
'config' => $this->getConfigFromDatabase($database),
48-
'name' => $connection->getName(),
48+
'name' => $connection->getDriverTitle(),
4949
'driver' => $connection->getDriverName(),
5050
'version' => $connection->getServerVersion(),
5151
'open_connections' => $this->getConnectionCount($connection),

src/Illuminate/Database/MariaDbConnection.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212

1313
class MariaDbConnection extends MySqlConnection
1414
{
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
public function getDriverTitle()
19+
{
20+
return 'SQLite';
21+
}
22+
1523
/**
1624
* Determine if the connected database is a MariaDB database.
1725
*

src/Illuminate/Database/MySqlConnection.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414

1515
class MySqlConnection extends Connection
1616
{
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public function getDriverTitle()
21+
{
22+
return $this->isMaria() ? 'MariaDB' : 'MySQL';
23+
}
24+
1725
/**
1826
* Escape a binary value for safe SQL embedding.
1927
*

src/Illuminate/Database/PostgresConnection.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212

1313
class PostgresConnection extends Connection
1414
{
15+
/**
16+
* {@inheritdoc}
17+
*/
18+
public function getDriverTitle()
19+
{
20+
return 'PostgreSQL';
21+
}
22+
1523
/**
1624
* Escape a binary value for safe SQL embedding.
1725
*

src/Illuminate/Database/Query/Grammars/Grammar.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,14 +1564,4 @@ public function getBitwiseOperators()
15641564
{
15651565
return $this->bitwiseOperators;
15661566
}
1567-
1568-
/**
1569-
* Get the number of open connections for a database.
1570-
*
1571-
* @return string|null
1572-
*/
1573-
public function compileConnectionCount()
1574-
{
1575-
return null;
1576-
}
15771567
}

src/Illuminate/Database/Query/Grammars/MySqlGrammar.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,9 +514,4 @@ protected function wrapJsonBooleanSelector($value)
514514

515515
return 'json_extract('.$field.$path.')';
516516
}
517-
518-
public function compileConnectionCount()
519-
{
520-
return 'show status where variable_name = "threads_connected"';
521-
}
522517
}

src/Illuminate/Database/Query/Grammars/PostgresGrammar.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -762,9 +762,4 @@ public function substituteBindingsIntoRawSql($sql, $bindings)
762762

763763
return $query;
764764
}
765-
766-
public function compileConnectionCount()
767-
{
768-
return 'select count(*) as "Value" from pg_stat_activity';
769-
}
770765
}

src/Illuminate/Database/Query/Grammars/SqlServerGrammar.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -571,9 +571,4 @@ protected function wrapTableValuedFunction($table)
571571

572572
return $table;
573573
}
574-
575-
public function compileConnectionCount()
576-
{
577-
return 'select count(*) Value from sys.dm_exec_sessions where status = "running"';
578-
}
579574
}

0 commit comments

Comments
 (0)