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(connector): added Connector interface #43

Merged
merged 2 commits into from
Apr 26, 2024
Merged

fix(connector): added Connector interface #43

merged 2 commits into from
Apr 26, 2024

Conversation

cnlangzi
Copy link
Member

Changes

  • added Connector interface to represents database query and command

@cnlangzi cnlangzi changed the title fix(connector): added Connector interface to fix(connector): added Connector interface Apr 25, 2024
Copy link

codecov bot commented Apr 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.88%. Comparing base (6f57b8a) to head (cf71457).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #43   +/-   ##
=======================================
  Coverage   75.88%   75.88%           
=======================================
  Files          42       42           
  Lines        1758     1758           
=======================================
  Hits         1334     1334           
  Misses        306      306           
  Partials      118      118           
Flag Coverage Δ
Unit-Tests 75.88% <ø> (ø)

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.

Copy link

deepsource-io bot commented Apr 25, 2024

Here's the code health analysis summary for commits 6f57b8a..cf71457. 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

@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: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: 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 to tell me if it was helpful.

// Query executes a query that returns multiple rows.
// It takes a query string and optional arguments.
// It returns a pointer to a Rows object and an error, if any.
Query(query string, args ...any) (*Rows, error)
Copy link

Choose a reason for hiding this comment

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

suggestion (code_clarification): Consider documenting the behavior when args is nil or empty.

Clarifying how the function behaves with no arguments could improve the usability and understanding of the API.

Suggested change
Query(query string, args ...any) (*Rows, error)
// Query executes a query that returns multiple rows.
// It takes a query string and optional arguments. If no arguments are provided,
// the query is executed without any parameter substitution.
// It returns a pointer to a Rows object and an error, if any.
Query(query string, args ...any) (*Rows, error)

// QueryRow executes a query that returns a single row.
// It takes a query string and optional arguments.
// It returns a pointer to a Row object.
QueryRow(query string, args ...any) *Row
Copy link

Choose a reason for hiding this comment

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

suggestion (code_clarification): Specify the return behavior when no rows are found.

It would be beneficial to define whether a nil Row or an error is returned when the query results in no rows, enhancing API predictability.

Suggested change
QueryRow(query string, args ...any) *Row
// QueryRow executes a query that returns a single row.
// It takes a query string and optional arguments.
// It returns a pointer to a Row object or nil if no rows are found.
QueryRow(query string, args ...any) *Row

// Exec executes a query that doesn't return any rows.
// It takes a query string and optional arguments.
// It returns a sql.Result object and an error, if any.
Exec(query string, args ...any) (sql.Result, error)
Copy link

Choose a reason for hiding this comment

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

suggestion (code_clarification): Clarify the expected behavior of Exec with invalid SQL commands.

Documenting how Exec handles syntax errors or unauthorized commands can help developers understand error handling.

Suggested change
Exec(query string, args ...any) (sql.Result, error)
// Exec executes a query that doesn't return any rows.
// It takes a query string and optional arguments.
// It returns a sql.Result object and an error, if any.
// Errors can include syntax errors in the query or issues like unauthorized commands,
// which will be returned as part of the error object.
Exec(query string, args ...any) (sql.Result, error)

@cnlangzi cnlangzi merged commit 1ade208 into main Apr 26, 2024
7 checks passed
@cnlangzi cnlangzi deleted the fix/db_conn branch April 26, 2024 01:57
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.

1 participant