Fix DB\IO return for unset pk name to be always string

Add Test for SELECT typ query and num rows type with dbReturn
This commit is contained in:
Clemens Schwaighofer
2022-03-22 20:17:30 +09:00
parent b7f594e683
commit 13fb22385b
2 changed files with 18 additions and 1 deletions

View File

@@ -3384,6 +3384,23 @@ final class CoreLibsDBIOTest extends TestCase
);
}
// if this is a select query, db dbReturn, dbReturnRow, dbReturnArray too
if (preg_match("/^(select|show|with) /i", $query)) {
$res = $db->dbReturn($query);
$this->assertEquals(
$expected_rows,
$db->dbGetNumRows()
);
$this->assertEquals(
$expected_cols,
$db->dbGetNumFields()
);
$this->assertEquals(
$expected_col_names,
$db->dbGetFieldNames()
);
}
// reset all data
$db->dbExec("TRUNCATE table_with_primary_key");
$db->dbExec("TRUNCATE table_without_primary_key");

View File

@@ -2874,7 +2874,7 @@ class IO
*/
public function dbGetInsertPKName(): string
{
return $this->insert_id_pk_name;
return (string)$this->insert_id_pk_name;
}
/**