Swift-Kuery-ORM
Swift-Kuery-ORM copied to clipboard
Add more options in findAll
This commit adds in options:
- ORDER BY clause for sorting
- OFFSET and LIMIT for retrieving a portion of the rows
This builds the appropriate SQL queries for the options listed above. This commit also adds in initial tests for the new options.
Signed-off-by: AnthonyAmanse [email protected]
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
0 out of 2 committers have signed the CLA.
:x: djones6
:x: AnthonyAmanse
You have signed the CLA already but the status is still pending? Let us recheck it.
Codecov Report
Merging #38 into master will increase coverage by
0.04%. The diff coverage is33.33%.
@@ Coverage Diff @@
## master #38 +/- ##
=========================================
+ Coverage 30.05% 30.1% +0.04%
=========================================
Files 6 6
Lines 1364 1385 +21
=========================================
+ Hits 410 417 +7
- Misses 954 968 +14
| Flag | Coverage Δ | |
|---|---|---|
| #SwiftKueryORM | 30.1% <33.33%> (+0.04%) |
:arrow_up: |
| Impacted Files | Coverage Δ | |
|---|---|---|
| Sources/SwiftKueryORM/Model.swift | 38.36% <33.33%> (-0.15%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 9d9618d...3c72ff7. Read the comment docs.
Hey @AnthonyAmanse, this looks really good! Just a few comments:
- We have some work planned around
QueryParamsand filtering so it would be good to just have these options in thefindAllcalls withoutQueryParams - Some verification needs to take place with the
OrderByparameter to prevent SQL Injection - for example verifying that the column is actually in the table? or using theParameter()function from SwiftKuery
Thank You
One more suggestion: would be to make the orderBy parameter accept multiple OrderBy instance since for example we would want to order by ascending name and descending age. The definition could be: orderBy: OrderBy? ...
@AnthonyAmanse Sorry - this needs now a rebase since your Swift-Kuery 2.0.0 PR just got merged and addressing the comments
@EnriqueL8 No worries. Changes made, used Order instead of OrderBy in functions. Also added a test case if column is not found in table
@EnriqueL8 Moved the logic to getOrderBy
@EnriqueL8 Feedbacks are always great! Merged the getOrderBy function instead of overloading. Sorted the rows using rows.sort instead of hardcoding it.
LGTM - Updated Branch because it is out-of-date Needs a Squash