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

feat: allow untagged fields to be ignored #285

Merged
merged 2 commits into from
Jul 27, 2021

Conversation

Deiz
Copy link
Contributor

@Deiz Deiz commented Jul 24, 2021

Per #284

This adds a SetIgnoreUntaggedFields function which sets the behavior when
encountering struct fields that do not have a db tag. By default this is
false; if set to true any field without a db tag will not be targeted by
Select or Scan operations.

@codecov
Copy link

codecov bot commented Jul 25, 2021

Codecov Report

Merging #285 (34b9894) into master (ff08a24) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #285      +/-   ##
==========================================
+ Coverage   96.77%   96.79%   +0.01%     
==========================================
  Files          60       60              
  Lines        3319     3335      +16     
==========================================
+ Hits         3212     3228      +16     
  Misses         91       91              
  Partials       16       16              
Flag Coverage Δ
unittests 96.79% <100.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
goqu.go 100.00% <100.00%> (ø)
internal/util/column_map.go 100.00% <100.00%> (ø)
internal/util/reflect.go 99.04% <100.00%> (+0.04%) ⬆️
sqlgen/expression_sql_generator.go 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ff08a24...34b9894. Read the comment docs.

This adds a `SetIgnoreUntaggedFields` function which sets the behavior when
encountering struct fields that do not have a db tag. By default this is
false; if set to true any field without a db tag will not be targeted by
Select or Scan operations.
@@ -111,3 +111,13 @@ func getColumnName(f *reflect.StructField, dbTag tag.Options) string {
}
return dbTag.Values()[0]
}

func shouldIgnoreField(dbTag tag.Options) bool {
if dbTag == "-" {
Copy link
Owner

Choose a reason for hiding this comment

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

Changing this back to dbTag.Equals("-") and use the dbTag.IsEmpty() on line 118 will fix the coverage issues. Then I'll merge and release

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I tossed the change on as an additional commit to avoid making the delta harder to review; please feel free to squash when merging.

@doug-martin doug-martin merged commit 350fd7f into doug-martin:master Jul 27, 2021
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.

2 participants