getOneOrFail() -> getFirstOneOrFail() & add getExactlyOneOrFail()
See original GitHub issueFeature Description
Rename getOneOrFail
and / or add getExactlyOneOrFail
method.
The Problem
I argue that the naming getOneOrFail
is ambiguous. Using getOneOrFail
with a query that returns more than one row could lead to hard to find bugs.
The Solution
BREAKING CHANGE: rename getOneOrFail
-> getFirstOneOrFail
.
FEATURE: add method getExactlyOneOrFail
Considered Alternatives
I know that this is a minor change and maybe not priorities but I think that clarity should always be increased if possible.
Relevant Database Driver(s)
DB Type | Relevant |
---|---|
aurora-data-api |
no |
aurora-data-api-pg |
no |
better-sqlite3 |
no |
cockroachdb |
no |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
yes |
nativescript |
no |
oracle |
no |
postgres |
yes |
react-native |
no |
sap |
no |
sqlite |
yes |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
Yes
- ✅ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don’t know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Select using Query Builder - typeorm - GitBook
getOne(). It builds the following SQL query: SELECT. user.id as userId, ... getOneOrFail will get a single result from the database, but if...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
findOneOrFail
appends LIMIT 1 that prevents you from getting multiple rows from the db.Maybe this feature is useful in some scenarios, but I don’t think we need to extend exist
find
API. Consider creating your repository like @Ginden did and use this method in your project.