vapor / fluent-kit

Swift ORM (queries, models, and relations) for NoSQL and SQL databases
MIT License
218 stars 116 forks source link

Add `hasNext` and `hasPrevious` properties #482

Closed noahpistilli closed 2 months ago

noahpistilli commented 2 years ago

This PR adds the properties hasNext and hasPrevious which are similar to the flask-sqlalchemy properties has_next and has_prev.

0xTim commented 2 years ago

Can you add some tests to this? Especially to check the boundaries/edge cases. Like count of 0, trying to pass in a page of -1 etc

noahpistilli commented 9 months ago

Can you add some tests to this? Especially to check the boundaries/edge cases. Like count of 0, trying to pass in a page of -1 etc

Should I add bounds to PageMetadata.page and PageMetadata.per then? Right now it will gladly accept a negative page number and a value of 0

0xTim commented 9 months ago

Can you add some tests to this? Especially to check the boundaries/edge cases. Like count of 0, trying to pass in a page of -1 etc

Should I add bounds to PageMetadata.page and PageMetadata.per then? Right now it will gladly accept a negative page number and a value of 0

Yes we definitely need tests and count checking for this

codecov-commenter commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 24.90%. Comparing base (614d3ec) to head (e796c6a).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #482 +/- ## ========================================== + Coverage 24.78% 24.90% +0.12% ========================================== Files 149 149 Lines 8660 8670 +10 ========================================== + Hits 2146 2159 +13 + Misses 6514 6511 -3 ``` | [Files with missing lines](https://app.codecov.io/gh/vapor/fluent-kit/pull/482?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [...luentKit/Query/Builder/QueryBuilder+Paginate.swift](https://app.codecov.io/gh/vapor/fluent-kit/pull/482?src=pr&el=tree&filepath=Sources%2FFluentKit%2FQuery%2FBuilder%2FQueryBuilder%2BPaginate.swift&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9GbHVlbnRLaXQvUXVlcnkvQnVpbGRlci9RdWVyeUJ1aWxkZXIrUGFnaW5hdGUuc3dpZnQ=) | `84.48% <100.00%> (+9.48%)` | :arrow_up: |
gwynne commented 2 months ago

Unfortunately, because PageMetadata is both public and Codable, this is a breaking change, and at this point I'm no longer accepting new features for Fluent 4. That being said, this functionality will be available in Fluent 5.