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(sqlbuilder): fixed WithWhere/WithOrderBy for empty builder #39

Merged
merged 1 commit into from
Apr 20, 2024

Conversation

cnlangzi
Copy link
Member

Fixes

  • fixed empty issue on WithWhere and WithOrderBy

Copy link

codecov bot commented Apr 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.30%. Comparing base (665c28e) to head (fdd1008).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #39      +/-   ##
==========================================
+ Coverage   75.28%   75.30%   +0.01%     
==========================================
  Files          42       42              
  Lines        1748     1749       +1     
==========================================
+ Hits         1316     1317       +1     
  Misses        318      318              
  Partials      114      114              
Flag Coverage Δ
Unit-Tests 75.30% <100.00%> (+0.01%) ⬆️

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 20, 2024

Here's the code health analysis summary for commits 665c28e..fdd1008. 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.

@cnlangzi cnlangzi merged commit d72e331 into main Apr 20, 2024
7 checks passed
@cnlangzi cnlangzi deleted the fix/empty_where_orderby branch April 20, 2024 14:39
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: 2 issues found
  • 🟢 Complexity: all looks good
  • 🟢 Docstrings: 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.

@@ -207,6 +207,26 @@ func TestBuilder(t *testing.T) {
require.Equal(t, now, vars[2])
},
},
{
name: "build_with_empty_where",
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Test case for empty WHERE clause should verify SQL syntax correctness.

The test verifies no errors and correct variable count, but it should also ensure that the SQL statement does not contain a WHERE clause when conditions are not added.

Suggested change
name: "build_with_empty_where",
name: "build_with_empty_where",
build: func() *Builder {
b := New().Select("orders")
return b
},
wantQuery: "SELECT * FROM orders",
wantArgs: []interface{}{},
wantErr: false,

@@ -78,6 +78,22 @@ func TestOrderByBuilder(t *testing.T) {
},
wanted: "SELECT * FROM users ORDER BY id ASC, created_at DESC, updated_at ASC",
},
{
name: "with_empty_order_by_should_work",
Copy link

Choose a reason for hiding this comment

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

suggestion (testing): Test case for empty ORDER BY should verify SQL syntax correctness.

The test checks for the absence of ORDER BY in the SQL, but it should also ensure that no ORDER BY clause is appended when no valid columns are specified.

Suggested change
name: "with_empty_order_by_should_work",
{
name: "with_empty_order_by_should_work",
build: func() *Builder {
b := New("SELECT * FROM users")
b.OrderBy() // No columns specified
return b
},
wanted: "SELECT * FROM users",
},

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