Skip to content

Commit c2fd167

Browse files
committed
Merge branch 'MAGETWO-63634' of github.com:magento-troll/magento2ce into MAGETWO-58456
2 parents fa91f51 + 9a7c892 commit c2fd167

File tree

3 files changed

+29
-34
lines changed

3 files changed

+29
-34
lines changed

lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,6 @@ protected function _removeDuplicateEntry($table, $fields, $ids)
13871387
*/
13881388
public function select()
13891389
{
1390-
// return new Select($this);
13911390
return $this->selectFactory->create($this);
13921391
}
13931392

lib/internal/Magento/Framework/DB/FieldDataConverter.php

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Framework\DB;
77

8+
use Magento\Framework\App\ObjectManager;
89
use Magento\Framework\DB\Adapter\AdapterInterface;
910
use Magento\Framework\DB\Query\Generator;
1011
use Magento\Framework\DB\DataConverter\DataConverterInterface;
@@ -26,68 +27,51 @@ class FieldDataConverter
2627
*/
2728
private $dataConverter;
2829

30+
/**
31+
* @var SelectFactory
32+
*/
33+
private $selectFactory;
34+
2935
/**
3036
* Constructor
3137
*
3238
* @param Generator $queryGenerator
3339
* @param DataConverterInterface $dataConverter
40+
* @param SelectFactory $selectFactory
3441
*/
3542
public function __construct(
3643
Generator $queryGenerator,
37-
DataConverterInterface $dataConverter
44+
DataConverterInterface $dataConverter,
45+
SelectFactory $selectFactory = null
3846
) {
3947
$this->queryGenerator = $queryGenerator;
4048
$this->dataConverter = $dataConverter;
49+
$this->selectFactory = $selectFactory ?: ObjectManager::getInstance()->get(SelectFactory::class);
4150
}
4251

4352
/**
44-
* Get converter select
53+
* Convert table field data from one representation to another uses DataConverterInterface
4554
*
4655
* @param AdapterInterface $connection
4756
* @param string $table
4857
* @param string $identifier
4958
* @param string $field
5059
* @param QueryModifierInterface|null $queryModifier
51-
*
52-
* @return Select
53-
*
54-
* @deprecated The method will be removed in MAGETWO-63944.
60+
* @return void
5561
*/
56-
public function getSelect(
62+
public function convert(
5763
AdapterInterface $connection,
5864
$table,
5965
$identifier,
6066
$field,
6167
QueryModifierInterface $queryModifier = null
6268
) {
63-
$select = $connection->select()
69+
$select = $this->selectFactory->create($connection)
6470
->from($table, [$identifier, $field])
6571
->where($field . ' IS NOT NULL');
6672
if ($queryModifier) {
6773
$queryModifier->modify($select);
6874
}
69-
70-
return $select;
71-
}
72-
73-
/**
74-
* Convert table field data from one representation to another uses DataConverterInterface
75-
*
76-
* @param AdapterInterface $connection
77-
* @param string $table
78-
* @param string $identifier
79-
* @param string $field
80-
* @param QueryModifierInterface|null $queryModifier
81-
* @return void
82-
*/
83-
public function convert(
84-
AdapterInterface $connection,
85-
$table,
86-
$identifier,
87-
$field,
88-
QueryModifierInterface $queryModifier = null
89-
) {
90-
$select = $this->getSelect($connection, $table, $identifier, $field, $queryModifier);
9175
$iterator = $this->queryGenerator->generate($identifier, $select);
9276
foreach ($iterator as $selectByRange) {
9377
$rows = $connection->fetchAll($selectByRange);

lib/internal/Magento/Framework/DB/Test/Unit/FieldDataConverterTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Framework\DB\Test\Unit;
77

8+
use Magento\Framework\DB\SelectFactory;
89
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
910
use Magento\Framework\DB\Query\Generator;
1011
use Magento\Framework\DB\Adapter\AdapterInterface;
@@ -45,6 +46,11 @@ class FieldDataConverterTest extends \PHPUnit_Framework_TestCase
4546
*/
4647
private $fieldDataConverter;
4748

49+
/**
50+
* @var \Magento\Framework\DB\SelectFactory|\PHPUnit_Framework_MockObject_MockObject
51+
*/
52+
private $selectFactoryMock;
53+
4854
protected function setUp()
4955
{
5056
$objectManager = new ObjectManager($this);
@@ -53,11 +59,16 @@ protected function setUp()
5359
$this->dataConverterMock = $this->getMock(DataConverterInterface::class);
5460
$this->selectMock = $this->getMock(Select::class, [], [], '', false);
5561
$this->queryModifierMock = $this->getMock(QueryModifierInterface::class);
62+
$this->selectFactoryMock = $this->getMockBuilder(SelectFactory::class)
63+
->disableOriginalConstructor()
64+
->setMethods([])
65+
->getMock();
5666
$this->fieldDataConverter = $objectManager->getObject(
5767
FieldDataConverter::class,
5868
[
5969
'queryGenerator' => $this->queryGeneratorMock,
60-
'dataConverter' => $this->dataConverterMock
70+
'dataConverter' => $this->dataConverterMock,
71+
'selectFactory' => $this->selectFactoryMock
6172
]
6273
);
6374
}
@@ -81,8 +92,9 @@ public function testConvert($useQueryModifier, $numQueryModifierCalls)
8192
]
8293
];
8394
$convertedValue = 'converted value';
84-
$this->connectionMock->expects($this->once())
85-
->method('select')
95+
$this->selectFactoryMock->expects($this->once())
96+
->method('create')
97+
->with($this->connectionMock)
8698
->willReturn($this->selectMock);
8799
$this->selectMock->expects($this->once())
88100
->method('from')

0 commit comments

Comments
 (0)