Skip to content

Commit 11e23a4

Browse files
committed
feat: tableExists() supports database name with dots
1 parent 712ab9c commit 11e23a4

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎system/Database/MySQLi/Connection.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public function escapeLikeStringDirect($str)
389389
*/
390390
protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
391391
{
392-
$sql = 'SHOW TABLES FROM ' . $this->escapeIdentifiers($this->database);
392+
$sql = 'SHOW TABLES FROM ' . $this->escapeIdentifier($this->database);
393393

394394
if ($tableName !== null) {
395395
return $sql . ' LIKE ' . $this->escape($tableName);

‎tests/system/Database/Live/ForgeTest.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ public function testCreateDatabaseWithDots(): void
7272

7373
$this->assertTrue($databaseCreated);
7474

75+
// Checks if tableExists() works.
76+
$config = config(Database::class)->{$this->DBGroup};
77+
$config['database'] = $dbName;
78+
$db = db_connect($config);
79+
$result = $db->tableExists('not_exist');
80+
81+
$this->assertFalse($result);
82+
83+
$db->close();
7584
if ($this->db->DBDriver !== 'SQLite3') {
7685
$this->forge->dropDatabase($dbName);
7786
}

0 commit comments

Comments
 (0)