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

fix(rows): doesn't close rows on Scan #49

Merged
merged 8 commits into from
Dec 12, 2024
Merged

fix(rows): doesn't close rows on Scan #49

merged 8 commits into from
Dec 12, 2024

Conversation

cnlangzi
Copy link
Member

@cnlangzi cnlangzi commented Dec 11, 2024

Fixes

Summary by Sourcery

Fix the premature closing of rows in the Scan method and add a test to verify correct scanning behavior.

Bug Fixes:

  • Fix the issue where rows were being closed prematurely in the Scan method, allowing users to manage the closing of rows themselves.

Tests:

  • Add a test case to ensure that scanning on rows works correctly without closing them prematurely.

Copy link

sourcery-ai bot commented Dec 11, 2024

Reviewer's Guide by Sourcery

This PR fixes a bug where database rows were being automatically closed during Scan operations. The implementation removes the deferred Close() call in the Scan method, allowing users to manage row closure explicitly. The change is verified through a new test case that demonstrates multiple Scan operations on the same rows object.

Sequence diagram for Scan operation without automatic row closure

sequenceDiagram
    actor User
    participant Rows
    participant Database

    User->>Rows: Call Scan(dest)
    Rows->>Database: Execute Scan
    Database-->>Rows: Return data
    Rows-->>User: Return data
    note right of User: User decides when to call Close()
Loading

File-Level Changes

Change Details Files
Remove automatic row closure in Scan method
  • Removed deferred Close() call from Scan method
  • Row closure responsibility now lies with the user
rows.go
Add test case to verify multiple Scan operations
  • Added test case 'scan_on_rows_should_work'
  • Test performs multiple Scan operations on the same rows object
  • Verifies correct data retrieval for multiple rows
rows_test.go

Assessment against linked issues

Issue Objective Addressed Explanation
#48 Remove automatic closing of sql.Rows in the Scan method

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @cnlangzi - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link

deepsource-io bot commented Dec 11, 2024

Here's the code health analysis summary for commits c243137..3f8d5d7. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Go LogoGo✅ SuccessView Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.71%. Comparing base (c243137) to head (3f8d5d7).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #49      +/-   ##
==========================================
- Coverage   77.12%   75.71%   -1.41%     
==========================================
  Files          46       46              
  Lines        1884     2368     +484     
==========================================
+ Hits         1453     1793     +340     
- Misses        306      456     +150     
+ Partials      125      119       -6     
Flag Coverage Δ
Unit-Tests 75.71% <100.00%> (-1.41%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cnlangzi cnlangzi merged commit fe93ae7 into main Dec 12, 2024
4 of 5 checks passed
@cnlangzi cnlangzi deleted the fix/rows_close branch December 12, 2024 03:38
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.

underlying sql.Rows should not be closed.
1 participant