Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArgumentsArray not populated from Bind values in UpdateQuery::buildSetClause #3

Open
hanomu opened this issue Apr 7, 2018 · 0 comments

Comments

@hanomu
Copy link

hanomu commented Apr 7, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant