Skip to content

Conversation

@shmax
Copy link
Contributor

@shmax shmax commented Sep 13, 2023

With this change, you can now iterate over a Relation result:

$books = Book::all();

foreach($books as $book) {
  echo $book->name;
}

This is accomplished using generators and individual calls to PDO::fetch, so it can generally result in a memory savings for large result sets.

@codecov
Copy link

codecov bot commented Sep 13, 2023

Codecov Report

Merging #65 (c1af770) into master (d59e14a) will increase coverage by 0.10%.
The diff coverage is 93.33%.

@@             Coverage Diff              @@
##             master      #65      +/-   ##
============================================
+ Coverage     95.33%   95.44%   +0.10%     
- Complexity      936      940       +4     
============================================
  Files            33       33              
  Lines          2272     2282      +10     
============================================
+ Hits           2166     2178      +12     
+ Misses          106      104       -2     
Files Changed Coverage Δ
lib/Connection.php 91.56% <ø> (ø)
lib/Relation.php 92.85% <91.30%> (+2.01%) ⬆️
lib/Model.php 97.99% <100.00%> (+<0.01%) ⬆️
lib/Table.php 96.60% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@shmax
Copy link
Contributor Author

shmax commented Sep 13, 2023

I tried valiantly to fix the issue with DatabaseTestCase not properly setting the default connection, but it exposed "write only" errors on the Sqlite tests in the CI, and I just couldn't figure out how to fix it. We can fight that battle in a different PR.

But in the interest of increasing code coverage enough to pass, I went ahead and implemented variadic lists on where and not...

Book::where("name = ?" , "Walden") // okay now

...which allowed me to remove some exceptions, and it's something we needed to do, anyway.

@shmax shmax merged commit 116bbe2 into master Sep 13, 2023
@shmax shmax deleted the iterator-support branch September 13, 2023 16:00
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.

2 participants