-
-
Notifications
You must be signed in to change notification settings - Fork 773
Add coalesce free function and Row method #1645
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
Conversation
Hello @philmitchell, I'm glad to hear about you :) Please give me a couple of days before I can review the pull request. |
This allows the user to call those methods with an Array, or any other collection at hand (including lazy ones) This change makes `return coalesce(columns.lazy.map { $0.name })` iterate lazily. Before this commit, `map` was returning a non-lazy Array.
Also, remove "essential".
Welcome to the GRDB contributors, @philmitchell! 🙂 I added a few commits, and we're going to be able to merge. c6781f4 replaces arrays like 761b00f and a17d72e test and fix the original code so that we can coalesce collections with less than 2 elements. Since we provide apis that accept a collection of values, we must wonder if it works with 0, 1, 2, etc. |
⛵ Shipped in 7.0.0-beta.3 |
Thanks, @groue, it's really a privilege! Sorry about all the cleanup you had to do, I will never be offended if you reject a PR w/ suggestions :) Hopefully we will figure out something around GRDB 7 and SQLCipher so that I can actually use this! |
You're very welcome, because coalesce addresses a real need! 😄 I was looking forward to merge, so I made a few changes on the go.
Yes, that's a big topic. Last year's development efforts have been absorbed by Swift Concurrency. I hope the path is now cleared for new improvements, such as restoring SQLCipher support in a way or another. |
As discussed with @groue, added
coalesce
methods as a best-effort alternative in cases where nil-coalescing fails. (I did investigate addressing the failure directly, but given the double optionals that represent null values (.some(.none)
), it seems unlikely to bear fruit.)Pull Request Checklist
development
branch.make smokeTest
terminal command runs without failure.