findAll doesn't return all the records #6401

Closed
opened 2026-01-22 15:32:32 +01:00 by admin · 3 comments
Owner

Originally created by @secit-pl on GitHub (Feb 13, 2020).

Bug Report

Q A
BC Break no
Version 2.7.0

I have strange problem. In one of my projects where I'm connecting with SQL Server findAll doesn't return all the records.

I have 4002 records in table.

count($repository->findAll()); // returns 3931

count($this->createQueryBuilder('duration')
->getEntityManager()
->getConnection()
->executeQuery('SELECT * FROM [TEST_DB].[dbo].[Test Journey Duration]')
->fetchAll()); // returns 4002

count($this->createQueryBuilder('duration')
->getEntityManager()
->createQuery('SELECT jd FROM App:Journey\Duration jd')
->getResult()); // returns 3931

The table is very simple, has no relations and contains only 5 columns: 3 x int, 2 x string

The stranger thing is that when I'm querying directly for the record which is not included in findAll using DQL

SELECT jd FROM App:Journey\Duration jd WHERE jd.id = 12915

the record is returned with all data. The $repository->find(12915) also finds the entity.

Originally created by @secit-pl on GitHub (Feb 13, 2020). ### Bug Report | Q | A |------------ | ------ | BC Break | no | Version | 2.7.0 I have strange problem. In one of my projects where I'm connecting with SQL Server findAll doesn't return all the records. I have 4002 records in table. count($repository->findAll()); // returns 3931 count($this->createQueryBuilder('duration') ->getEntityManager() ->getConnection() ->executeQuery('SELECT * FROM [TEST_DB].[dbo].[Test Journey Duration]') ->fetchAll()); // returns 4002 count($this->createQueryBuilder('duration') ->getEntityManager() ->createQuery('SELECT jd FROM App:Journey\Duration jd') ->getResult()); // returns 3931 The table is very simple, has no relations and contains only 5 columns: 3 x int, 2 x string The stranger thing is that when I'm querying directly for the record which is not included in findAll using DQL ```dql SELECT jd FROM App:Journey\Duration jd WHERE jd.id = 12915 ``` the record is returned with all data. The $repository->find(12915) also finds the entity.
admin closed this issue 2026-01-22 15:32:32 +01:00
Author
Owner

@SenseException commented on GitHub (Feb 13, 2020):

What does the SQL query look like when you call $repository->findAll()?

@SenseException commented on GitHub (Feb 13, 2020): What does the SQL query look like when you call `$repository->findAll()`?
Author
Owner

@beberlei commented on GitHub (Feb 13, 2020):

@secit-pl did you maybe define the ID field on a column that is not actually unique?

@beberlei commented on GitHub (Feb 13, 2020): @secit-pl did you maybe define the ID field on a column that is not actually unique?
Author
Owner

@beberlei commented on GitHub (Sep 25, 2020):

No feedback here, closing for now.

@beberlei commented on GitHub (Sep 25, 2020): No feedback here, closing for now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6401