-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Load label ID in NewLabels #2045
Conversation
models/issue_label.go
Outdated
@@ -98,7 +98,11 @@ func (label *Label) ForegroundColor() template.CSS { | |||
|
|||
// NewLabels creates new label(s) for a repository. | |||
func NewLabels(labels ...*Label) error { | |||
_, err := x.Insert(labels) |
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.
why not just x.Insert(labels...)
?
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.
And of course, a transaction is needed.
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.
x.Insert(labels...)
doesn't compile, since labels
is of type []*Label
, and the argument to x.Insert(..)
has to be of type []interface{}
.
I don't understand why is a transaction needed? From what I can tell, the call to x.Insert(..)
will just generate one INSERT
command.
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.
x.Insert(slice)
is one INSERT command, x.Insert(slice...)
will generate N INSERT command. A transaction for a better performance.
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.
Oh, I see. Updated to use a transaction.
LGTM |
7a17f9e
to
c0b2ef7
Compare
Rebased to run CI again |
LGTM |
Fix bug in
NewLabels(..)
where theID
field for the labels were not populated. This caused a problem in thePOST /repos/:user/:repo/labels
API endpoint, where the response label would have an"id"
attribute of 0.Also update the unit test to check that
ID
has been populated.