-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Changing the position of the emptied variable #3997
Closed
Closed
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4f51944
Changing the position of the emptied variable
dfrnks a711cce
correcting unit test and code correction
dfrnks 4e54fce
Remove space
dfrnks 90121e3
New unit test. test ArrayIterator
dfrnks 6ebd9a1
New unit test. test ArrayIterator
dfrnks c7ba8bb
Change the unit test
dfrnks 03937e3
CS fixed
dfrnks 8f70206
/** @scrutinizer ignore-call */
dfrnks 038b00d
Update tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
dfrnks 039d351
Remove use ArrayIterator
dfrnks 70ecd18
Change the return of executeCacheQuery
dfrnks 40a452b
Fixed CS
dfrnks 3cc7fe2
Add @throws DBALException
dfrnks 0ca34b8
Remove @throws DBALException
dfrnks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,7 +165,7 @@ public function testDontFinishNoCache() : void | |
|
||
$this->hydrateStmt($stmt, FetchMode::NUMERIC); | ||
|
||
self::assertCount(2, $this->sqlLogger->queries); | ||
self::assertCount(1, $this->sqlLogger->queries); | ||
} | ||
|
||
public function testFetchAllAndFinishSavesCache() : void | ||
|
@@ -194,6 +194,26 @@ public function testFetchAllColumn() : void | |
self::assertEquals([1], $stmt->fetchAll(FetchMode::COLUMN)); | ||
} | ||
|
||
public function testGetIterator() : void | ||
{ | ||
$query = $this->connection->getDatabasePlatform() | ||
->getDummySelectSQL('1'); | ||
|
||
$qcp = new QueryCacheProfile(0, 0, new ArrayCache()); | ||
|
||
$stmt = $this->connection->executeCacheQuery($query, [], [], $qcp); | ||
$stmt->/** @scrutinizer ignore-call */ | ||
getIterator(); | ||
$stmt->closeCursor(); | ||
|
||
$stmt = $this->connection->executeCacheQuery($query, [], [], $qcp); | ||
|
||
$iterator = $stmt->/** @scrutinizer ignore-call */ | ||
getIterator(); | ||
SenseException marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
self::assertCount(1, $iterator); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a valid behavior to expect. The fact that the iterator internally calls |
||
} | ||
|
||
/** | ||
* @param array<int, array<int, int|string>> $expectedResult | ||
*/ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, isn't this test supposed to have 2 queries executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, a second query he took from the cache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It previously expected 2 queries in the test and I want to know what's the reason for this test. I'll need help from @beberlei, who implemented this test in #69 a long time ago.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test was incorrect because, just will save the query in $this->sqlLogger->queries when the query are execute in the database.
dbal/lib/Doctrine/DBAL/Connection.php
Lines 894 to 897 in 4c03ed8
When the query are in the cache, they return before
dbal/lib/Doctrine/DBAL/Connection.php
Lines 886 to 897 in 4c03ed8
The reason are the cache doesn't work before, when we use fetch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, which is why I approved if at first, but if there's another reason why @beberlei expected 2 in the past, I want to know and would like to be on the save side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was recently changed in #4048. It's an improvement, not a bugfix, so this change shouldn't be made in
2.10.x.
.