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

Add new fieldas tag to set AS name for SELECT #79

Merged
merged 2 commits into from
Jul 24, 2022
Merged

Conversation

huandu
Copy link
Owner

@huandu huandu commented Jul 21, 2022

See #78 for discussion about this feature.

@coveralls
Copy link

coveralls commented Jul 21, 2022

Coverage Status

Coverage increased (+0.02%) to 95.848% when pulling ebd3252 on feature-fieldas into 20e19b9 on master.

README.md Outdated
@@ -136,6 +136,7 @@ type ATable struct {
Field2 int `db:"field2"` // Use "db" in field tag to set column name used in SQL.
Field3 int64 `db:"field3" fieldtag:"foo,bar"` // Set fieldtag to a field. We can use methods like `Struct#SelectForTag` to use it.
Field4 int64 `db:"field4" fieldtag:"foo"` // If we use `s.SelectForTag(table, "foo")`, columnes of SELECT are field3 and field4.
Field5As string `db:"field5" fieldas:"FIELD5"` // Use "fieldas" in field tag to set AS name used in SELECT.

Choose a reason for hiding this comment

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

Suggested change
Field5As string `db:"field5" fieldas:"FIELD5"` // Use "fieldas" in field tag to set AS name used in SELECT.
Field5As string `db:"field5" fieldas:"FIELD5"` // Use "fieldas" in field tag to set AS name used in SELECT.

Choose a reason for hiding this comment

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

Is there a better description than "AS name" that we could use? Might help users searching for this feature in your library. I'm not sure if there is an official term, but I can see people using "alias" or "AS clause".

Could do something like:

// Use "fieldas" in field tag to set a column alias/clause (AS) used in SELECT.

Or:

// Use "fieldas" in field tag to set the returned column name (AS) using in SELECT.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Updated.

@huandu huandu merged commit a283436 into master Jul 24, 2022
@huandu huandu deleted the feature-fieldas branch April 2, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants