-
Notifications
You must be signed in to change notification settings - Fork 1k
Improve sqlexist template #2896
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
Conversation
3a6993e to
f3d80b3
Compare
f3d80b3 to
a3d9ae4
Compare
masseelch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, please see my comment. I think a switch is more elegant here. @a8m
| {{- if $.HasOneFieldID }} | ||
| _, err := {{ $receiver }}.FirstID(ctx) | ||
| {{- else }} | ||
| _, err := {{ $receiver }}.First(ctx) | ||
| {{- end }} | ||
| switch { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| {{- if $.HasOneFieldID }} | |
| _, err := {{ $receiver }}.FirstID(ctx) | |
| {{- else }} | |
| _, err := {{ $receiver }}.First(ctx) | |
| {{- end }} | |
| switch { | |
| switch _, err := {{ $receiver }}.First{{ if $.HasOneFieldID }}ID{{ end }}(ctx); { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a8m
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, @Aagosh10. Looks good.
Please, fix the minor suggestion.
|
Thanks for the contribution, @Aagosh10. |
Use .First and .FirstID for sqlExist