mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 13:12:41 +00:00
Change "rebind" to "retype" to better reflect what actually happens
This commit is contained in:
parent
31aea0a06a
commit
bc9fcb975f
6 changed files with 14 additions and 14 deletions
|
@ -18,18 +18,18 @@ abstract class AbstractStatement implements Statement {
|
|||
return $this->runArray($values);
|
||||
}
|
||||
|
||||
public function rebind(...$bindings): bool {
|
||||
return $this->rebindArray($bindings);
|
||||
public function retype(...$bindings): bool {
|
||||
return $this->retypeArray($bindings);
|
||||
}
|
||||
|
||||
public function rebindArray(array $bindings, bool $append = false): bool {
|
||||
public function retypeArray(array $bindings, bool $append = false): bool {
|
||||
if (!$append) {
|
||||
$this->types = [];
|
||||
}
|
||||
foreach ($bindings as $binding) {
|
||||
if (is_array($binding)) {
|
||||
// recursively flatten any arrays, which may be provided for SET or IN() clauses
|
||||
$this->rebindArray($binding, true);
|
||||
$this->retypeArray($binding, true);
|
||||
} else {
|
||||
$binding = trim(strtolower($binding));
|
||||
if (strpos($binding, "strict ")===0) {
|
||||
|
|
|
@ -24,7 +24,7 @@ class PDOStatement extends AbstractStatement {
|
|||
public function __construct(\PDO $db, \PDOStatement $st, array $bindings = []) {
|
||||
$this->db = $db;
|
||||
$this->st = $st;
|
||||
$this->rebindArray($bindings);
|
||||
$this->retypeArray($bindings);
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
|
|
|
@ -31,7 +31,7 @@ class Statement extends \JKingWeb\Arsse\Db\AbstractStatement {
|
|||
public function __construct(\SQLite3 $db, \SQLite3Stmt $st, array $bindings = []) {
|
||||
$this->db = $db;
|
||||
$this->st = $st;
|
||||
$this->rebindArray($bindings);
|
||||
$this->retypeArray($bindings);
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
|
|
|
@ -29,6 +29,6 @@ interface Statement {
|
|||
|
||||
public function run(...$values): Result;
|
||||
public function runArray(array $values = []): Result;
|
||||
public function rebind(...$bindings): bool;
|
||||
public function rebindArray(array $bindings): bool;
|
||||
public function retype(...$bindings): bool;
|
||||
public function retypeArray(array $bindings): bool;
|
||||
}
|
||||
|
|
|
@ -35,10 +35,10 @@ class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest {
|
|||
$s = new self::$imp($this->c, $nativeStatement);
|
||||
$types = array_unique(Statement::TYPES);
|
||||
foreach ($types as $type) {
|
||||
$s->rebindArray([$strict ? "strict $type" : $type]);
|
||||
$s->retypeArray([$strict ? "strict $type" : $type]);
|
||||
$val = $s->runArray([$input])->getRow()['value'];
|
||||
$this->assertSame($expectations[$type], $val, "Binding from type $type failed comparison.");
|
||||
$s->rebind(...[$strict ? "strict $type" : $type]);
|
||||
$s->retype(...[$strict ? "strict $type" : $type]);
|
||||
$val = $s->run(...[$input])->getRow()['value'];
|
||||
$this->assertSame($expectations[$type], $val, "Binding from type $type failed comparison.");
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest {
|
|||
) as pass"
|
||||
);
|
||||
$s = new self::$imp($this->c, $nativeStatement);
|
||||
$s->rebindArray([$type, $type]);
|
||||
$s->retypeArray([$type, $type]);
|
||||
$act = (bool) $s->run(...[$value, $value])->getRow()['pass'];
|
||||
$this->assertTrue($act);
|
||||
}
|
||||
|
|
|
@ -36,10 +36,10 @@ class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest {
|
|||
$s = new self::$imp($this->c, $nativeStatement);
|
||||
$types = array_unique(Statement::TYPES);
|
||||
foreach ($types as $type) {
|
||||
$s->rebindArray([$strict ? "strict $type" : $type]);
|
||||
$s->retypeArray([$strict ? "strict $type" : $type]);
|
||||
$val = $s->runArray([$input])->getRow()['value'];
|
||||
$this->assertSame($expectations[$type], $val, "Binding from type $type failed comparison.");
|
||||
$s->rebind(...[$strict ? "strict $type" : $type]);
|
||||
$s->retype(...[$strict ? "strict $type" : $type]);
|
||||
$val = $s->run(...[$input])->getRow()['value'];
|
||||
$this->assertSame($expectations[$type], $val, "Binding from type $type failed comparison.");
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ class TestStatement extends \JKingWeb\Arsse\Test\AbstractTest {
|
|||
) as pass"
|
||||
);
|
||||
$s = new self::$imp($this->c, $nativeStatement);
|
||||
$s->rebind(...[$type, $type]);
|
||||
$s->retype(...[$type, $type]);
|
||||
$act = (bool) $s->run(...[$value, $value])->getRow()['pass'];
|
||||
$this->assertTrue($act);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue