Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Aagosh10
Copy link
Contributor

@Aagosh10 Aagosh10 commented Sep 2, 2022

Use .First and .FirstID for sqlExist

@Aagosh10 Aagosh10 force-pushed the sqlexist-template branch 2 times, most recently from 3a6993e to f3d80b3 Compare September 2, 2022 11:44
Copy link
Collaborator

@masseelch masseelch left a 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

Comment on lines 252 to 257
{{- if $.HasOneFieldID }}
_, err := {{ $receiver }}.FirstID(ctx)
{{- else }}
_, err := {{ $receiver }}.First(ctx)
{{- end }}
switch {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
{{- if $.HasOneFieldID }}
_, err := {{ $receiver }}.FirstID(ctx)
{{- else }}
_, err := {{ $receiver }}.First(ctx)
{{- end }}
switch {
switch _, err := {{ $receiver }}.First{{ if $.HasOneFieldID }}ID{{ end }}(ctx); {

Copy link
Member

Choose a reason for hiding this comment

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

Not sure if you see my suggestion correctly because I see this:
image

But I mean this:
image

Copy link
Member

@a8m a8m left a 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.

@a8m a8m merged commit 326fe42 into ent:master Sep 4, 2022
@a8m
Copy link
Member

a8m commented Sep 4, 2022

Thanks for the contribution, @Aagosh10.

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.

3 participants