Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/386'
Browse files Browse the repository at this point in the history
Close #386
Fix #383
  • Loading branch information
michalbundyra committed Dec 31, 2019
2 parents 19c9bfb + 0c49dc2 commit 6dbaecf
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -36,6 +36,8 @@ All notable changes to this project will be documented in this file, in reverse

- [#342](https://github.com/zendframework/zend-db/pull/342) fixes deleting from aliased tables.

- [#386](https://github.com/zendframework/zend-db/pull/386) fixes too strongly casting integer parameters in PDO adapter.

## 2.10.0 - 2019-02-25

### Added
Expand Down
2 changes: 0 additions & 2 deletions src/Adapter/Driver/Pdo/Statement.php
Expand Up @@ -269,8 +269,6 @@ protected function bindParametersFromContainer()
foreach ($parameters as $name => &$value) {
if (is_bool($value)) {
$type = \PDO::PARAM_BOOL;
} elseif (is_int($value)) {
$type = \PDO::PARAM_INT;
} else {
$type = \PDO::PARAM_STR;
}
Expand Down
3 changes: 2 additions & 1 deletion test/integration/Adapter/Driver/Pdo/Mysql/QueryTest.php
Expand Up @@ -16,7 +16,8 @@ public function getQueriesWithRowResult()
return [
['SELECT * FROM test WHERE id = ?', [1], ['id' => 1, 'name' => 'foo', 'value' => 'bar']],
['SELECT * FROM test WHERE id = :id', [':id' => 1], ['id' => 1, 'name' => 'foo', 'value' => 'bar']],
['SELECT * FROM test WHERE id = :id', ['id' => 1], ['id' => 1, 'name' => 'foo', 'value' => 'bar']]
['SELECT * FROM test WHERE id = :id', ['id' => 1], ['id' => 1, 'name' => 'foo', 'value' => 'bar']],
['SELECT * FROM test WHERE name = ?', [123], ['id' => '4', 'name' => '123', 'value' => 'bar']],
];
}

Expand Down
4 changes: 3 additions & 1 deletion test/integration/TestFixtures/mysql.sql
Expand Up @@ -7,7 +7,9 @@ CREATE TABLE IF NOT EXISTS test (

INSERT INTO test (name, value) VALUES
('foo', 'bar'),
('bar', 'baz');
('bar', 'baz'),
('123a', 'bar'),
('123', 'bar');

CREATE TABLE IF NOT EXISTS test_charset (
id INT NOT NULL AUTO_INCREMENT,
Expand Down
10 changes: 10 additions & 0 deletions test/unit/Adapter/Driver/Pdo/StatementIntegrationTest.php
Expand Up @@ -71,4 +71,14 @@ public function testStatementExecuteWillUsePdoStrByDefaultWhenBinding()
);
$this->statement->execute(['foo' => 'bar']);
}

public function testStatementExecuteWillUsePdoStrForIntWhenBinding()
{
$this->pdoStatementMock->expects($this->any())->method('bindParam')->with(
$this->equalTo(':foo'),
$this->equalTo(123),
$this->equalTo(\PDO::PARAM_STR)
);
$this->statement->execute(['foo' => 123]);
}
}

0 comments on commit 6dbaecf

Please sign in to comment.