Skip to content

Commit 29a7b3d

Browse files
committed
Merge remote-tracking branch 'origin/2.4-develop' into MCP-767
2 parents 05fc0ca + 7255b67 commit 29a7b3d

File tree

2 files changed

+28
-0
lines changed
  • dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo
  • lib/internal/Magento/Framework/DB/Adapter/Pdo

2 files changed

+28
-0
lines changed

dev/tests/integration/testsuite/Magento/Framework/DB/Adapter/Pdo/MysqlTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,30 @@ protected function tearDown(): void
3434
restore_error_handler();
3535
}
3636

37+
/**
38+
* Check PDO stringify fetches options
39+
*/
40+
public function testStringifyFetchesTrue(): void
41+
{
42+
$tableName = $this->resourceConnection->getTableName('table_with_int_column');
43+
$columnId = 'integer_column';
44+
$adapter = $this->getDbAdapter();
45+
46+
$table = $adapter
47+
->newTable($tableName)
48+
->addColumn($columnId, Table::TYPE_INTEGER);
49+
$adapter->createTable($table);
50+
$adapter->insert($tableName, [$columnId => 100]);
51+
52+
$select = $adapter->select()
53+
->from($tableName)
54+
->columns([$columnId])
55+
->limit(1);
56+
$result = $adapter->fetchOne($select);
57+
$this->assertIsString($result);
58+
$adapter->dropTable($tableName);
59+
}
60+
3761
/**
3862
* Test lost connection re-initializing
3963
*

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ protected function _connect()
420420
$this->_config['driver_options'][\PDO::MYSQL_ATTR_MULTI_STATEMENTS] = false;
421421
}
422422

423+
if (!isset($this->_config['driver_options'][\PDO::ATTR_STRINGIFY_FETCHES])) {
424+
$this->_config['driver_options'][\PDO::ATTR_STRINGIFY_FETCHES] = true;
425+
}
426+
423427
$this->logger->startTimer();
424428
parent::_connect();
425429
$this->logger->logStats(LoggerInterface::TYPE_CONNECT, '');

0 commit comments

Comments
 (0)