Skip to content

Commit 150f5bc

Browse files
committed
Adjust tests for named parameters in SQL
1 parent e65ff35 commit 150f5bc

File tree

4 files changed

+3
-33
lines changed

4 files changed

+3
-33
lines changed

_test/QueryBuilderTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,4 @@ public function test_join()
2323
$qb->addLeftJoin('second', 'fourth', 'fourth', 'second.foo=fourth.foo');
2424
$this->assertEquals(['first', 'second', 'fourth', 'third'], array_keys($qb->from));
2525
}
26-
27-
public function test_placeholders()
28-
{
29-
$qb = new QueryBuilder();
30-
31-
32-
$foo = $qb->addValue('foo');
33-
$bar = $qb->addValue('bar');
34-
35-
$input = "this is $foo and $bar and $foo again";
36-
$expect = "this is ? and ? and ? again";
37-
$values = ['foo', 'bar', 'foo'];
38-
39-
$output = $qb->fixPlaceholders($input);
40-
41-
$this->assertEquals($expect, $output[0]);
42-
$this->assertEquals($values, $output[1]);
43-
}
44-
45-
public function test_placeholderfail()
46-
{
47-
$this->expectException(StructException::class);
48-
$qb = new QueryBuilder();
49-
$qb->fixPlaceholders('this has unknown placeholder :!!val7!!:');
50-
}
5126
}

_test/StructTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ protected function getLang($key)
111111
*/
112112
protected function cleanWS($string)
113113
{
114-
return preg_replace('/\s+/s', '', $string);
114+
return preg_replace(['/\s+/s', '/\:val(\d{1,3})/'], ['', '?'], $string);
115115
}
116116

117117
/**

_test/mock/QueryBuilder.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ class QueryBuilder extends meta\QueryBuilder
88
{
99
public $from;
1010

11-
public function fixPlaceholders($sql)
12-
{
13-
return parent::fixPlaceholders($sql);
14-
}
15-
1611
/**
1712
* for debugging where statements
1813
*
1914
* @return array ($sql, $opts)
2015
*/
2116
public function getWhereSQL()
2217
{
23-
return $this->fixPlaceholders($this->filters()->toSQL());
18+
return [$this->filters()->toSQL(), array_values($this->values)];
2419
}
2520
}

meta/QueryBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public function getSQL()
241241
'ORDER BY ' . implode(",\n", $this->orderby) . "\n";
242242
}
243243

244-
return [$sql, $this->values];
244+
return [$sql, array_values($this->values)];
245245
}
246246

247247
/**

0 commit comments

Comments
 (0)