Skip to content
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

maybe_single with no matching rows returns None #231

Merged
merged 1 commit into from
Mar 7, 2023
Merged

Conversation

anand2312
Copy link
Contributor

What kind of change does this PR introduce?

Bug fix - closes #230 . The maybe_single method now returns None when the query returns 0 rows.

What is the current behavior?

maybe_single errors out on responses with 0 rows, while trying to create a SingleAPIResponse with it's data field set to None, which pydantic rejects.

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Mar 7, 2023

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.46%.

Quality metrics Before After Change
Complexity 1.84 ⭐ 1.84 ⭐ 0.00
Method Length 52.97 ⭐ 52.42 ⭐ -0.55 👍
Working memory 7.44 🙂 7.33 🙂 -0.11 👍
Quality 78.78% 79.24% 0.46% 👍
Other metrics Before After Change
Lines 668 656 -12
Changed files Quality Before Quality After Quality Change
postgrest/_async/request_builder.py 78.76% ⭐ 79.22% ⭐ 0.46% 👍
postgrest/_sync/request_builder.py 78.80% ⭐ 79.26% ⭐ 0.46% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
postgrest/_async/request_builder.py AsyncSelectRequestBuilder.text_search 4 ⭐ 116 🙂 10 😞 62.91% 🙂 Extract out complex expressions
postgrest/_sync/request_builder.py SyncSelectRequestBuilder.text_search 4 ⭐ 116 🙂 10 😞 62.91% 🙂 Extract out complex expressions
postgrest/_async/request_builder.py AsyncRequestBuilder.upsert 0 ⭐ 60 ⭐ 13 😞 69.70% 🙂 Extract out complex expressions
postgrest/_sync/request_builder.py SyncRequestBuilder.upsert 0 ⭐ 60 ⭐ 13 😞 69.70% 🙂 Extract out complex expressions
postgrest/_async/request_builder.py AsyncRequestBuilder.insert 0 ⭐ 54 ⭐ 11 😞 73.95% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@codecov
Copy link

codecov bot commented Mar 7, 2023

Codecov Report

Patch coverage: 50.00% and no project coverage change

Comparison is base (67572ba) 91.51% compared to head (849f306) 91.51%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #231   +/-   ##
=======================================
  Coverage   91.51%   91.51%           
=======================================
  Files          24       24           
  Lines        1167     1167           
=======================================
  Hits         1068     1068           
  Misses         99       99           
Impacted Files Coverage Δ
postgrest/_async/request_builder.py 79.61% <50.00%> (ø)
postgrest/_sync/request_builder.py 86.40% <50.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@anand2312 anand2312 requested a review from J0 March 7, 2023 14:21
@J0 J0 merged commit d148298 into master Mar 7, 2023
@J0 J0 deleted the fix/empty-maybe-single branch March 7, 2023 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

maybe_single throws an error when there are 0 rows in the DB
2 participants