mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Fix remaining test problems
This commit is contained in:
parent
c40f39e34e
commit
0f2da754c5
9 changed files with 25 additions and 5 deletions
|
@ -204,4 +204,8 @@ abstract class AbstractDriver implements Driver {
|
|||
public function prepare(string $query, ...$paramType): Statement {
|
||||
return $this->prepareArray($query, $paramType);
|
||||
}
|
||||
|
||||
public function stringOutput(): bool {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ interface Driver {
|
|||
* The tokens the implementation must understand are:
|
||||
*
|
||||
* - "greatest": the GREATEST function implemented by PostgreSQL and MySQL
|
||||
* - "least": the LEAST function implemented by PostgreSQL and MySQL
|
||||
* - "nocase": the name of a general-purpose case-insensitive collation sequence
|
||||
* - "like": the case-insensitive LIKE operator
|
||||
* - "integer": the integer type to use for explicit casts
|
||||
|
@ -91,4 +92,7 @@ interface Driver {
|
|||
* This should be restricted to quick maintenance; in SQLite terms it might include ANALYZE, but not VACUUM
|
||||
*/
|
||||
public function maintenance(): bool;
|
||||
|
||||
/** Reports whether the implementation will coerce integer and float values to text (string) */
|
||||
public function stringOutput(): bool;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use JKingWeb\Arsse\Db\Exception;
|
|||
class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
|
||||
use ExceptionBuilder;
|
||||
|
||||
protected const SQL_MODE = "ANSI_QUOTES,HIGH_NOT_PRECEDENCE,NO_BACKSLASH_ESCAPES,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,STRICT_ALL_TABLES";
|
||||
protected const SQL_MODE = "ANSI_QUOTES,HIGH_NOT_PRECEDENCE,NO_BACKSLASH_ESCAPES,NO_ENGINE_SUBSTITUTION,PIPES_AS_CONCAT,STRICT_ALL_TABLES,NO_UNSIGNED_SUBTRACTION";
|
||||
protected const TRANSACTIONAL_LOCKS = false;
|
||||
|
||||
/** @var \mysqli */
|
||||
|
|
|
@ -29,7 +29,7 @@ class PDODriver extends Driver {
|
|||
try {
|
||||
$this->db = new \PDO($dsn, $user, $password, [
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => false,
|
||||
]);
|
||||
} catch (\PDOException $e) {
|
||||
$msg = $e->getMessage();
|
||||
|
|
|
@ -232,4 +232,8 @@ class Driver extends \JKingWeb\Arsse\Db\AbstractDriver {
|
|||
$this->exec("ANALYZE");
|
||||
return true;
|
||||
}
|
||||
|
||||
public function stringOutput(): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,4 +60,8 @@ class PDODriver extends Driver {
|
|||
public function prepareArray(string $query, array $paramTypes): \JKingWeb\Arsse\Db\Statement {
|
||||
return new PDOStatement($this->db, $query, $paramTypes);
|
||||
}
|
||||
|
||||
public function stringOutput(): bool {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,4 +81,8 @@ class PDODriver extends AbstractPDODriver {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function stringOutput(): bool {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -422,7 +422,7 @@ abstract class AbstractTest extends \PHPUnit\Framework\TestCase {
|
|||
// serialize to CSV, null being represented by no value
|
||||
if ($v === null) {
|
||||
$row[] = "";
|
||||
} elseif (static::$stringOutput || is_string($v)) {
|
||||
} elseif ($drv->stringOutput() || is_string($v)) {
|
||||
$row[] = '"'.str_replace('"', '""', (string) $v).'"';
|
||||
} else {
|
||||
$row[] = (string) $v;
|
||||
|
|
|
@ -16,7 +16,7 @@ trait MySQLPDO {
|
|||
protected static $dbResultClass = \JKingWeb\Arsse\Db\PDOResult::class;
|
||||
protected static $dbStatementClass = \JKingWeb\Arsse\Db\MySQL\PDOStatement::class;
|
||||
protected static $dbDriverClass = \JKingWeb\Arsse\Db\MySQL\PDODriver::class;
|
||||
protected static $stringOutput = true;
|
||||
protected static $stringOutput = false;
|
||||
|
||||
public static function dbInterface() {
|
||||
try {
|
||||
|
@ -33,7 +33,7 @@ trait MySQLPDO {
|
|||
$dsn = "mysql:".implode(";", $dsn);
|
||||
$d = new \PDO($dsn, Arsse::$conf->dbMySQLUser, Arsse::$conf->dbMySQLPass, [
|
||||
\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => true,
|
||||
\PDO::ATTR_STRINGIFY_FETCHES => false,
|
||||
\PDO::MYSQL_ATTR_MULTI_STATEMENTS => false,
|
||||
]);
|
||||
foreach (\JKingWeb\Arsse\Db\MySQL\PDODriver::makeSetupQueries() as $q) {
|
||||
|
|
Loading…
Reference in a new issue