Bug #78129

Statement::rowCount not reliable for SELECT queries

Added by Oliver Hader almost 3 years ago. Updated 12 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2016-10-02
Due date:
% Done:

100%

TYPO3 Version:
8
PHP Version:
7.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

see https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Driver/Statement.php#L127

... taken from the PHPdoc comment:

Returns the number of rows affected by the last DELETE, INSERT, or UPDATE statement
executed by the corresponding object.

If the last SQL statement executed by the associated Statement object was a SELECT statement,
some databases may return the number of rows returned by that statement. However,
this behaviour is not guaranteed for all databases and should not be
relied on for portable applications.

In particular rowCount() on valid SELECT statements for SQLite as DBMS returns 0 when fetch() would retrieve existing records. Thus, using rowCount() should be avoided and replaced by proper COUNT statements instead - if required at all.


Related issues

Related to TYPO3 Core - Bug #85228: Invalid count query in SuggestWizardDefaultReceiver Closed 2018-06-11
Related to TYPO3 Core - Bug #85359: BE-Pagebrowser broken Closed 2018-06-23
Precedes TYPO3 Core - Bug #85743: An exception occurred if I click on List Closed 2016-10-03 2016-10-03

Associated revisions

Revision 0367dbda (diff)
Added by Susanne Moog over 1 year ago

[BUGFIX] Statement::rowCount not reliable for SELECT queries

Concerning the usage of Statement::rowCount() the Doctrine DBAL
documentation states the following:

Returns the number of rows affected by the last
DELETE, INSERT, or UPDATE statement
executed by the corresponding object.

For default configurations using MySQL as platform,
rowCount() is returning the expected
value for SELECT statements as well.
However, on other DBMS this value will be zero
as mentioned in the documentation - for instance
SQLite is a candidate for that.

For retrieving the row count for given criteria, the count()
expression has to be used explicitly.

Resolves: #78129
Releases: master
Change-Id: Id28d72a1a21e8615ec45b63d4aecc100d03a39a3
Reviewed-on: https://review.typo3.org/50083
Reviewed-by: Oliver Hader <>
Tested-by: Oliver Hader <>
Tested-by: TYPO3com <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>

History

#1 Updated by Gerrit Code Review almost 3 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#2 Updated by Gerrit Code Review almost 3 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#3 Updated by Benni Mack almost 3 years ago

  • Sprint Focus set to Stabilization Sprint

#4 Updated by Benni Mack almost 3 years ago

  • Target version set to 8.4

#5 Updated by Gerrit Code Review almost 3 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#6 Updated by Gerrit Code Review almost 3 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#7 Updated by Benni Mack almost 3 years ago

  • Target version changed from 8.4 to 8.5

#8 Updated by Morton Jonuschat almost 3 years ago

  • Category changed from 999 to Database API (Doctrine DBAL)

#9 Updated by Benni Mack over 2 years ago

  • Target version changed from 8.5 to 8.6

#10 Updated by Benni Mack over 2 years ago

  • Target version changed from 8.6 to 8 LTS

#11 Updated by Christian Kuhn over 2 years ago

  • Target version deleted (8 LTS)
  • Sprint Focus deleted (Stabilization Sprint)

#12 Updated by Gerrit Code Review over 1 year ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#13 Updated by Gerrit Code Review over 1 year ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#14 Updated by Gerrit Code Review over 1 year ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#15 Updated by Gerrit Code Review over 1 year ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#16 Updated by Gerrit Code Review over 1 year ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/50083

#17 Updated by Susanne Moog over 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#18 Updated by Alexander Stehlik over 1 year ago

  • Related to Bug #85228: Invalid count query in SuggestWizardDefaultReceiver added

#19 Updated by Georg Ringer about 1 year ago

  • Related to Bug #85359: BE-Pagebrowser broken added

#20 Updated by Stephan GroƟberndt about 1 year ago

  • Precedes Bug #85743: An exception occurred if I click on List added

#21 Updated by Benni Mack 12 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF