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

ResultCacheStatement::fetchAll() doesn't respect fetch mode on subsequent calls #4033

Closed
morozov opened this issue May 27, 2020 · 2 comments · Fixed by #4034
Closed

ResultCacheStatement::fetchAll() doesn't respect fetch mode on subsequent calls #4033

morozov opened this issue May 27, 2020 · 2 comments · Fixed by #4034

Comments

@morozov
Copy link
Member

morozov commented May 27, 2020

Bug Report

Q A
BC Break no
Version 2.10.2

When a cached result set is used with fetchAll() and the fetch mode is different from the one used to populate the cache, the original fetch mode is used instead.

$conn = DriverManager::getConnection([
    'driver' => 'pdo_mysql',
    'user'   => 'root',
    'dbname' => 'mysql',
]);

$conn->getConfiguration()
    ->setResultCacheImpl(new ArrayCache());

$qcp = new QueryCacheProfile(0, 'test');

$stmt = $conn->executeQuery("SELECT 'foo' bar", [], [], $qcp);
$stmt->fetchAll(FetchMode::NUMERIC);
$stmt->closeCursor();

$stmt = $conn->executeQuery("SELECT 'foo' bar", [], [], $qcp);
var_dump($stmt->fetchAll(FetchMode::ASSOCIATIVE));

Current behaviour

array(1) {
  [0] =>
  array(1) {
    [0] =>
    string(3) "foo"
  }
}

Expected behaviour

array(1) {
  [0] =>
  array(1) {
    'bar' =>
    string(3) "foo"
  }
}
@morozov
Copy link
Member Author

morozov commented Jun 11, 2020

Closing as fixed by #4034.

@morozov morozov closed this as completed Jun 11, 2020
@morozov morozov self-assigned this Jun 11, 2020
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant