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

[6.x] Apply limit to database rather than collection #30148

Merged
merged 5 commits into from
Oct 3, 2019
Merged

[6.x] Apply limit to database rather than collection #30148

merged 5 commits into from
Oct 3, 2019

Conversation

morrislaptop
Copy link
Contributor

From #30144 with fixed tests


If the following conditions are true:

  • The test is using DatabaseTransactions rather than RefreshDatabase;
  • There is a large dataset for the table under test;
  • The assertDatabaseHas assertion is being used; and
  • The assertion fails

The entire table is put into memory causing allowed memory fatal errors.

This is because the limit is applied on a Collection after putting all the records in memory.

This change puts the limit on the database query so only the limited amount of records go into memory.

This avoids errors in tests for users and does not break any existing features.

@driesvints driesvints changed the title Apply limit to database rather than collection [6.x] Apply limit to database rather than collection Sep 30, 2019
@staudenmeir
Copy link
Contributor

staudenmeir commented Oct 1, 2019

The same code is used in SoftDeletedInDatabase, we should also adjust that.

@morrislaptop
Copy link
Contributor Author

@staudenmeir done, thanks!

@taylorotwell taylorotwell merged commit 7109d5f into laravel:6.x Oct 3, 2019
Gman98ish added a commit to Gman98ish/framework that referenced this pull request Oct 4, 2019
Remove brackets arround URL php artisan serve (laravel#30168)

To allow opening the development URL in Visual Studio Code with ctrl + click the bracket after the URL needs to be removed.
This patch wil remove the brackets around the url.

add test for sorted middlewares (laravel#30166)

[6.x] Apply limit to database rather than collection (laravel#30148)

* Apply limit to database rather than collection

For HasInDatabase.php

* Fix tests

* Add to SoftDeleted trait as well

* Update HasInDatabase.php

* Update SoftDeletedInDatabase.php

[6.x] Allow to use scoped macro in nested queries (laravel#30127)

* Allow to use scoped macro in nested queries.

* Use newQueryWithoutRelationships
Gman98ish added a commit to Gman98ish/framework that referenced this pull request Oct 4, 2019
Remove brackets arround URL php artisan serve (laravel#30168)

To allow opening the development URL in Visual Studio Code with ctrl + click the bracket after the URL needs to be removed.
This patch wil remove the brackets around the url.

add test for sorted middlewares (laravel#30166)

[6.x] Apply limit to database rather than collection (laravel#30148)

* Apply limit to database rather than collection

For HasInDatabase.php

* Fix tests

* Add to SoftDeleted trait as well

* Update HasInDatabase.php

* Update SoftDeletedInDatabase.php

[6.x] Allow to use scoped macro in nested queries (laravel#30127)

* Allow to use scoped macro in nested queries.

* Use newQueryWithoutRelationships
i-bajrai pushed a commit to i-bajrai/framework that referenced this pull request Oct 4, 2019
* Apply limit to database rather than collection

For HasInDatabase.php

* Fix tests

* Add to SoftDeleted trait as well

* Update HasInDatabase.php

* Update SoftDeletedInDatabase.php
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

Successfully merging this pull request may close these issues.

3 participants