This is an automated email from the ASF dual-hosted git repository.
linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/answer.git
The following commit(s) were added to refs/heads/dev by this push:
new 6d847204 pass pointer instead of slice to Find(...) method
6d847204 is described below
commit 6d84720404e445e0ddb88a667d012d9eea593001
Author: Nikita Sivukhin <[email protected]>
AuthorDate: Mon Jan 13 01:02:52 2025 +0400
pass pointer instead of slice to Find(...) method
---
internal/repo/answer/answer_repo.go | 4 ++--
internal/repo/collection/collection_repo.go | 2 +-
internal/repo/question/question_repo.go | 2 +-
internal/repo/role/power_repo.go | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/internal/repo/answer/answer_repo.go
b/internal/repo/answer/answer_repo.go
index 2c2787f6..35de6c17 100644
--- a/internal/repo/answer/answer_repo.go
+++ b/internal/repo/answer/answer_repo.go
@@ -198,7 +198,7 @@ func (ar *answerRepo) GetAnswerList(ctx context.Context,
answer *entity.Answer)
answerList = make([]*entity.Answer, 0)
answer.ID = uid.DeShortID(answer.ID)
answer.QuestionID = uid.DeShortID(answer.QuestionID)
- err = ar.data.DB.Context(ctx).Find(answerList, answer)
+ err = ar.data.DB.Context(ctx).Find(&answerList, answer)
if err != nil {
err =
errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}
@@ -216,7 +216,7 @@ func (ar *answerRepo) GetAnswerPage(ctx context.Context,
page, pageSize int, ans
answer.ID = uid.DeShortID(answer.ID)
answer.QuestionID = uid.DeShortID(answer.QuestionID)
answerList = make([]*entity.Answer, 0)
- total, err = pager.Help(page, pageSize, answerList, answer,
ar.data.DB.Context(ctx))
+ total, err = pager.Help(page, pageSize, &answerList, answer,
ar.data.DB.Context(ctx))
if err != nil {
err =
errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}
diff --git a/internal/repo/collection/collection_repo.go
b/internal/repo/collection/collection_repo.go
index 1aecaf47..a3faacdb 100644
--- a/internal/repo/collection/collection_repo.go
+++ b/internal/repo/collection/collection_repo.go
@@ -108,7 +108,7 @@ func (cr *collectionRepo) GetCollection(ctx
context.Context, id int) (collection
// GetCollectionList get collection list all
func (cr *collectionRepo) GetCollectionList(ctx context.Context, collection
*entity.Collection) (collectionList []*entity.Collection, err error) {
collectionList = make([]*entity.Collection, 0)
- err = cr.data.DB.Context(ctx).Find(collectionList, collection)
+ err = cr.data.DB.Context(ctx).Find(&collectionList, collection)
err =
errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
return
}
diff --git a/internal/repo/question/question_repo.go
b/internal/repo/question/question_repo.go
index 117ee38f..c144411b 100644
--- a/internal/repo/question/question_repo.go
+++ b/internal/repo/question/question_repo.go
@@ -272,7 +272,7 @@ func (qr *questionRepo) FindByID(ctx context.Context, id
[]string) (questionList
func (qr *questionRepo) GetQuestionList(ctx context.Context, question
*entity.Question) (questionList []*entity.Question, err error) {
question.ID = uid.DeShortID(question.ID)
questionList = make([]*entity.Question, 0)
- err = qr.data.DB.Context(ctx).Find(questionList, question)
+ err = qr.data.DB.Context(ctx).Find(&questionList, question)
if err != nil {
return questionList,
errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}
diff --git a/internal/repo/role/power_repo.go b/internal/repo/role/power_repo.go
index 8da7c663..bbd600e9 100644
--- a/internal/repo/role/power_repo.go
+++ b/internal/repo/role/power_repo.go
@@ -44,7 +44,7 @@ func NewPowerRepo(data *data.Data) role.PowerRepo {
// GetPowerList get list all
func (pr *powerRepo) GetPowerList(ctx context.Context, power *entity.Power)
(powerList []*entity.Power, err error) {
powerList = make([]*entity.Power, 0)
- err = pr.data.DB.Context(ctx).Find(powerList, power)
+ err = pr.data.DB.Context(ctx).Find(&powerList, power)
if err != nil {
err =
errors.InternalServer(reason.DatabaseError).WithError(err).WithStack()
}