Skip to content

Commit

Permalink
upgrade crate-pdo dependency to 0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
seut committed Nov 27, 2014
1 parent 43dc361 commit 7d6e95f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"require": {
"php": "~5.5",
"doctrine/dbal": "2.3.5",
"crate/crate-pdo": "0.0.4"
"crate/crate-pdo": "0.0.5"
},
"autoload": {
"psr-0": {
Expand Down
3 changes: 2 additions & 1 deletion src/Crate/DBAL/Types/ArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace Crate\DBAL\Types;

use Crate\PDO\PDO;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;

Expand Down Expand Up @@ -52,7 +53,7 @@ public function getName()
*/
public function getBindingType()
{
return \PDO::PARAM_INPUT_OUTPUT;
return PDO::PARAM_ARRAY;
}

public function convertToDatabaseValue($value, AbstractPlatform $platform)
Expand Down
3 changes: 2 additions & 1 deletion src/Crate/DBAL/Types/MapType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

namespace Crate\DBAL\Types;

use Crate\PDO\PDO;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;

Expand Down Expand Up @@ -57,7 +58,7 @@ public function getName()
*/
public function getBindingType()
{
return \PDO::PARAM_INPUT_OUTPUT;
return PDO::PARAM_OBJECT;
}

public function convertToDatabaseValue($value, AbstractPlatform $platform)
Expand Down
2 changes: 1 addition & 1 deletion test/Crate/Test/DBAL/DBALFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ protected function onNotSuccessfulTest(\Exception $e)
$queries = "";
$i = count($this->_sqlLoggerStack->queries);
foreach (array_reverse($this->_sqlLoggerStack->queries) AS $query) {
$params = array_map(function($p) { if (is_object($p)) return get_class($p); else return "'".$p."'"; }, $query['params'] ?: array());
$params = array_map(function($p) { if (is_object($p)) return get_class($p); else return "'".print_r($p, true)."'"; }, $query['params'] ?: array());
$queries .= ($i+1).". SQL: '".$query['sql']."' Params: ".implode(", ", $params).PHP_EOL;
$i--;
}
Expand Down
29 changes: 14 additions & 15 deletions test/Crate/Test/DBAL/Functional/DataAccessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
namespace Crate\Test\DBAL\Functional;

use Crate\DBAL\Types\MapType;
use Crate\DBAL\Types\ArrayType;
use Crate\Test\DBAL\DBALFunctionalTestCase;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Types\Type;
Expand Down Expand Up @@ -67,7 +66,7 @@ public function setUp()
'test_string' => 'foo',
'test_datetime' => new \DateTime('2010-01-01 10:10:10'),
'test_array' => array('foo','bar'),
'test_object' => array('id'=>1, 'name'=>'foo', 'value'=>1.234),
'test_object' => array('id'=>1, 'name'=>'foo', 'value'=>1.234,),
), array('integer','string','timestamp','array','map'));
$this->refresh('fetch_table');
}
Expand All @@ -87,8 +86,8 @@ public function testPrepareWithBindValue()
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);

$stmt->bindValue(1, 1);
$stmt->bindValue(2, 'foo');
$stmt->bindValue(1, 1, PDO::PARAM_INT);
$stmt->bindValue(2, 'foo', PDO::PARAM_STR);
$stmt->execute();

$row = $stmt->fetch(\PDO::FETCH_ASSOC);
Expand All @@ -105,8 +104,8 @@ public function testPrepareWithBindParam()
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);

$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->bindParam(1, $paramInt, PDO::PARAM_INT);
$stmt->bindParam(2, $paramStr, PDO::PARAM_STR);
$stmt->execute();

$row = $stmt->fetch(\PDO::FETCH_ASSOC);
Expand All @@ -123,8 +122,8 @@ public function testPrepareWithFetchAll()
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);

$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->bindParam(1, $paramInt, PDO::PARAM_INT);
$stmt->bindParam(2, $paramStr, PDO::PARAM_STR);
$stmt->execute();

$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
Expand All @@ -134,7 +133,7 @@ public function testPrepareWithFetchAll()
'test_string' => 'foo',
'test_datetime' => 1262340610000,
'test_array' => array('foo', 'bar'),
'test_object' => ((object) array('id'=>1, 'name'=>'foo', 'value'=>1.234))
'test_object' => array('id'=>1, 'name'=>'foo', 'value'=>1.234)
), $rows[0]);

$this->assertEquals($this->_conn->convertToPHPValue($rows[0]['test_datetime'], 'timestamp'),
Expand All @@ -157,8 +156,8 @@ public function testPrepareWithFetchAllBoth()
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);

$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->bindParam(1, $paramInt, PDO::PARAM_INT);
$stmt->bindParam(2, $paramStr, PDO::PARAM_STR);
$stmt->execute();

$rows = $stmt->fetchAll(\PDO::FETCH_BOTH);
Expand All @@ -175,8 +174,8 @@ public function testPrepareWithFetchColumn()
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);

$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->bindParam(1, $paramInt, PDO::PARAM_INT);
$stmt->bindParam(2, $paramStr, PDO::PARAM_STR);
$stmt->execute();

$column = $stmt->fetchColumn();
Expand All @@ -192,8 +191,8 @@ public function testPrepareWithIterator()
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);

$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->bindParam(1, $paramInt, PDO::PARAM_INT);
$stmt->bindParam(2, $paramStr, PDO::PARAM_STR);
$stmt->execute();

$rows = array();
Expand Down
4 changes: 2 additions & 2 deletions test/Crate/Test/DBAL/Functional/WriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ public function insertRows()
'test_int' => 1,
'test_string' => 'foo',
'test_float' => 1.234,
'test_arr' => array('foo','bar'),
'test_array' => array('foo','bar'),
'test_obj' => array('id'=>1, 'name'=>'foo', 'value'=>1.234),
), array('integer','string','float','array','map')));
$this->assertEquals(1, $this->_conn->insert('write_table', array(
'test_int' => 2,
'test_string' => 'bar',
'test_float' => 2.345,
'test_arr' => array('bar','foo'),
'test_array' => array('bar','foo'),
'test_obj' => array('id'=>2, 'name'=>'bar', 'value'=>2.345),
), array('integer','string','float','array','map')));

Expand Down

0 comments on commit 7d6e95f

Please sign in to comment.