diff --git a/lib/Db/PDOError.php b/lib/Db/PDOError.php index 25b2a08f..dcb8aa45 100644 --- a/lib/Db/PDOError.php +++ b/lib/Db/PDOError.php @@ -37,7 +37,7 @@ trait PDOError { case SQLite3::SQLITE_MISMATCH: return [ExceptionInput::class, 'engineTypeViolation', $err[2]]; } - break; + break; // @codeCoverageIgnore case "mysql": switch ($err[1]) { case 1205: @@ -47,7 +47,7 @@ trait PDOError { case 1366: return [ExceptionInput::class, 'engineTypeViolation', $err[2]]; } - break; + break; // @codeCoverageIgnore } return [Exception::class, "engineErrorGeneral", $err[0]."/".$err[1].": ".$err[2]]; // @codeCoverageIgnore default: diff --git a/lib/Db/PDOStatement.php b/lib/Db/PDOStatement.php index 2115ce5c..d5a36c5f 100644 --- a/lib/Db/PDOStatement.php +++ b/lib/Db/PDOStatement.php @@ -30,11 +30,12 @@ class PDOStatement extends AbstractStatement { protected function prepare(string $query): bool { try { + // PDO statements aren't usually evaluated at creation, and so should not fail $this->st = $this->db->prepare($query); return true; - } catch (\PDOException $e) { - list($excClass, $excMsg, $excData) = $this->exceptionBuild(); - throw new $excClass($excMsg, $excData); + } catch (\PDOException $e) { // @codeCoverageIgnore + list($excClass, $excMsg, $excData) = $this->exceptionBuild(); // @codeCoverageIgnore + throw new $excClass($excMsg, $excData); // @codeCoverageIgnore } } diff --git a/lib/Db/SQLite3/Statement.php b/lib/Db/SQLite3/Statement.php index 2de3e3bd..8c393ca6 100644 --- a/lib/Db/SQLite3/Statement.php +++ b/lib/Db/SQLite3/Statement.php @@ -37,11 +37,12 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement { protected function prepare(string $query): bool { try { + // statements aren't evaluated at creation, and so should not fail $this->st = $this->db->prepare($query); return true; - } catch (\Exception $e) { - list($excClass, $excMsg, $excData) = $this->exceptionBuild(); - throw new $excClass($excMsg, $excData); + } catch (\Exception $e) { // @codeCoverageIgnore + list($excClass, $excMsg, $excData) = $this->exceptionBuild(); // @codeCoverageIgnore + throw new $excClass($excMsg, $excData); // @codeCoverageIgnore } } diff --git a/tests/cases/Db/BaseDriver.php b/tests/cases/Db/BaseDriver.php index 91992e45..08f96349 100644 --- a/tests/cases/Db/BaseDriver.php +++ b/tests/cases/Db/BaseDriver.php @@ -95,6 +95,7 @@ abstract class BaseDriver extends \JKingWeb\Arsse\Test\AbstractTest { public function testTranslateAToken() { $this->assertRegExp("/^[a-z][a-z0-9]*$/i", $this->drv->sqlToken("greatest")); + $this->assertRegExp("/^\"?[a-z][a-z0-9_\-]*\"?$/i", $this->drv->sqlToken("nocase")); $this->assertSame("distinct", $this->drv->sqlToken("distinct")); } diff --git a/tests/cases/Db/MySQLPDO/TestStatement.php b/tests/cases/Db/MySQLPDO/TestStatement.php index a0727ea8..f956302c 100644 --- a/tests/cases/Db/MySQLPDO/TestStatement.php +++ b/tests/cases/Db/MySQLPDO/TestStatement.php @@ -8,7 +8,7 @@ namespace JKingWeb\Arsse\TestCase\Db\MySQLPDO; /** * @group slow - * @covers \JKingWeb\Arsse\Db\PDOStatement + * @covers \JKingWeb\Arsse\Db\MySQL\PDOStatement * @covers \JKingWeb\Arsse\Db\PDOError */ class TestStatement extends \JKingWeb\Arsse\TestCase\Db\BaseStatement { protected static $implementation = "PDO MySQL";