Open
Description
I'll apologise in advance for not providing a pull request, mainly because the fix (described at the bottom of this text) is trivial. For the sake of thoroughness I'll provide some example code and the expected output vs the actual output.
Example code:
$row = ['field1' => 1, 'field2' => 2, 'field3' => 3];
$query = new \Magsql\Universal\Query\UpdateQuery();
$query->update('some_table')->set($row)->where()->equal('id', 4);
$driver = new \Magsql\Driver\MySQLDriver();
$driver->alwaysBindValues(true);
$args = new \Magsql\ArgumentArray;
$sql = $query->toSql($driver, $args);
var_dump($sql, (array) $args);
Expected output:
string(81) "UPDATE some_table SET field1= :p1, field2 = :p2, field3 = :p3 WHERE id = :p4"
array(4) {
[":p1"]=>
int(1)
[":p2"]=>
int(2)
[":p3"]=>
int(3)
[":p4"]=>
int(4)
}
Actual output:
string(81) "UPDATE some_table SET field1 = :p1, field2 = :p2, field3 = :p3 WHERE id = :p4"
array(1) {
[":p4"]=>
int(4)
}
Fix:
UpdateQuery::buildSetClause
is missing the $args
parameter in a call to BaseDriver::deflate
. Adding the $args
variable as second parameter fixes the issue.
Metadata
Metadata
Assignees
Labels
No labels