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

Empty getCurrentPageResults #254

Open
akorz opened this issue Oct 9, 2018 · 6 comments
Open

Empty getCurrentPageResults #254

akorz opened this issue Oct 9, 2018 · 6 comments

Comments

@akorz
Copy link

akorz commented Oct 9, 2018

Hello,

I have code

        $qb = $this->createQueryBuilder('country');
        $adapter = new DoctrineORMAdapter($qb);
        $this->pagerfanta = new Pagerfanta($adapter);
        $this->pagerfanta->setMaxPerPage(10);
        $this->pagerfanta->setCurrentPage(1);

        var_dump($this->pagerfanta->getNbResults());
        var_dump($this->pagerfanta->getCurrentPageResults());

the result

int(242)
object(ArrayIterator)#12190 (1) { ["storage":"ArrayIterator":private]=> array(0) { } }

But I see following lines in dev.log

[2018-10-09 17:37:43] doctrine.DEBUG: SELECT DISTINCT id_0 FROM (SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.iso_code AS iso_code_2, c0_.phone_code AS phone_code_3, c0_.deleted_at AS deleted_at_4 FROM countries c0_) dctrn_result LIMIT 10 [] []
[2018-10-09 17:37:43] doctrine.DEBUG: SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.iso_code AS iso_code_2, c0_.phone_code AS phone_code_3, c0_.deleted_at AS deleted_at_4 FROM countries c0_ WHERE c0_.id IN (?) [["[object] (App\\Domain\\Country\\ValueObject\\CountryId: 0042840f-843e-457d-9250-b1e22d8d6d5e)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 01c4f446-48a9-413f-9225-7138c0e39f98)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 029bed5c-35f2-4c7d-812c-7d7d3d886be1)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 02c0460d-8902-4cf7-a070-e6404f321c25)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 0315d760-5dea-412e-8242-7eceb7373375)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 033d07bb-c4ce-4166-991b-a5441bcf2b7e)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 035ce32a-3b21-40e8-ae58-ee3a15fd6c71)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 054f444e-c8d2-48ad-a058-5bd94ff8a133)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 05bafdf7-a31e-4d84-8db7-a03f3bb0d670)","[object] (App\\Domain\\Country\\ValueObject\\CountryId: 0873c562-db8a-4189-af35-82d5d80b7fe9)"]] []
[2018-10-09 17:37:43] doctrine.DEBUG: SELECT COUNT(*) AS dctrn_count FROM (SELECT DISTINCT id_0 FROM (SELECT c0_.id AS id_0, c0_.name AS name_1, c0_.iso_code AS iso_code_2, c0_.phone_code AS phone_code_3, c0_.deleted_at AS deleted_at_4 FROM countries c0_) dctrn_result) dctrn_table [] []

So looks like something happens. At least I get right NB count. But empty getCurrentPageResults. May be problem that my Id is CountryID UUID based?

@akorz
Copy link
Author

akorz commented Oct 11, 2018

Somehow it started to work with

$adapter = new DoctrineORMAdapter($qb, true, false);

What is it?

@sampart
Copy link
Collaborator

sampart commented Oct 15, 2018

That's odd. Does it still work if you do this?

$adapter = new DoctrineORMAdapter($qb, true, null);

(i.e. changing false to null)

@mcbuckets
Copy link

@sampart can confirm it doesn't work with null. Had the same issue. It works with false though. Can anyone explain?

@akorz
Copy link
Author

akorz commented Oct 26, 2018

@mcbuckets Thanks for checking. I've not had a time to check on my side :(

@sampart
Copy link
Collaborator

sampart commented Oct 29, 2018

If anyone wants a bit of context on Output Walkers, #220 may help.

@sampart
Copy link
Collaborator

sampart commented Oct 29, 2018

I'm afraid I don't understand Doctrine's internals well enough to explain this issue, sorry! @akorz I think you may be on the right lines when you say it's due to the specifics of your model. You could also experiment with passing a more configured querybuilder rather than the standard one you get by only passing an alias to createQueryBuilder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants