mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-18 17:00:02 +02:00
Use ID or Where to instead directly use Get when load object from database (#11925)
* Use ID or Where to instead directly use Get when load object from database * Apply suggestions from code review Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
61cd0ce866
commit
1645d4a5d8
9 changed files with 25 additions and 28 deletions
|
@ -136,9 +136,8 @@ func GetAttachmentByID(id int64) (*Attachment, error) {
|
|||
}
|
||||
|
||||
func getAttachmentByID(e Engine, id int64) (*Attachment, error) {
|
||||
attach := &Attachment{ID: id}
|
||||
|
||||
if has, err := e.Get(attach); err != nil {
|
||||
attach := &Attachment{}
|
||||
if has, err := e.ID(id).Get(attach); err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
return nil, ErrAttachmentNotExist{ID: id, UUID: ""}
|
||||
|
@ -147,8 +146,8 @@ func getAttachmentByID(e Engine, id int64) (*Attachment, error) {
|
|||
}
|
||||
|
||||
func getAttachmentByUUID(e Engine, uuid string) (*Attachment, error) {
|
||||
attach := &Attachment{UUID: uuid}
|
||||
has, err := e.Get(attach)
|
||||
attach := &Attachment{}
|
||||
has, err := e.Where("uuid=?", uuid).Get(attach)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if !has {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue