-
Notifications
You must be signed in to change notification settings - Fork 293
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
Add existsBy #1437
Add existsBy #1437
Conversation
, parseEntityValues | ||
, parseExistsResult | ||
, updatePersistValue | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imports diff here was just stylish-haskell, aside from adding parseExistsResult
on line 27
CI is failing with a bunch of
which looks like it's the I wonder, if I hadn't edited anything in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put a default impl on the class so it's a safer for backwards compatibility
## 2.14.4.4 | ||
|
||
* [#1460] https://github.com/yesodweb/persistent/pull/1460 | ||
* [#1460](https://github.com/yesodweb/persistent/pull/1460) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches the format in the rest of the changelog, where the PR number links to the link, but the URL itself is not shown. I can revert these changes if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great - thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, thank you so much!
## 2.14.4.4 | ||
|
||
* [#1460] https://github.com/yesodweb/persistent/pull/1460 | ||
* [#1460](https://github.com/yesodweb/persistent/pull/1460) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great - thank you!
This adds
existsBy
inPersistUniqueRead
, as a more efficient version ofisJust <$> getBy uniq
.The intent is to provide an (a) more convenient to type and (b) more efficient way to query existence of a row by unique key.
The SQL is a combination of the
exists
andgetBy
impls, and looks likeSELECT EXISTS (SELECT 1 FROM ...constraints...)
.The performance difference shouldn't be large, but conceivably on wider tables (or with heavy columns eg. JSON or binary blobs),
existsBy
would require less serialization (just a single response column) and may allow the query planner to do an index-only plan.What do you think?
Before submitting your PR, check that you've:
@since
declarations to the Haddockstylish-haskell
on any changed files..editorconfig
file for details)After submitting your PR:
(unreleased)
on the Changelog