From 8e83ed89fa0d8f5f498fa652e9944500127d4aae Mon Sep 17 00:00:00 2001 From: skeris Date: Thu, 11 Apr 2024 19:26:02 +0300 Subject: [PATCH] return questiontype as string --- dal/db_query/queries.sql | 2 +- dal/sqlcgen/db.go | 2 +- dal/sqlcgen/models.go | 2 +- dal/sqlcgen/queries.sql.go | 6 +++--- repository/answer/answer.go | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/dal/db_query/queries.sql b/dal/db_query/queries.sql index 9e9ee56..9cebbf8 100644 --- a/dal/db_query/queries.sql +++ b/dal/db_query/queries.sql @@ -280,7 +280,7 @@ WHERE privilege_name = $2 -- name: GetAllAnswersByQuizID :many SELECT DISTINCT ON (a.question_id) - a.content, a.created_at, a.question_id, a.id, q.questiontype, quiz.qid + a.content, a.created_at, a.question_id, a.id, q.questiontype::Text as questiontype, quiz.qid FROM answer a JOIN diff --git a/dal/sqlcgen/db.go b/dal/sqlcgen/db.go index 7090fb4..6e5541c 100644 --- a/dal/sqlcgen/db.go +++ b/dal/sqlcgen/db.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 package sqlcgen diff --git a/dal/sqlcgen/models.go b/dal/sqlcgen/models.go index 75ae972..5a42d12 100644 --- a/dal/sqlcgen/models.go +++ b/dal/sqlcgen/models.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 package sqlcgen diff --git a/dal/sqlcgen/queries.sql.go b/dal/sqlcgen/queries.sql.go index 78fc8f0..9dac75c 100644 --- a/dal/sqlcgen/queries.sql.go +++ b/dal/sqlcgen/queries.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.26.0 +// sqlc v1.25.0 // source: queries.sql package sqlcgen @@ -805,7 +805,7 @@ func (q *Queries) GetAccountWithPrivileges(ctx context.Context, userID sql.NullS const getAllAnswersByQuizID = `-- name: GetAllAnswersByQuizID :many SELECT DISTINCT ON (a.question_id) - a.content, a.created_at, a.question_id, a.id, q.questiontype, quiz.qid + a.content, a.created_at, a.question_id, a.id, q.questiontype::Text as questiontype, quiz.qid FROM answer a JOIN @@ -823,7 +823,7 @@ type GetAllAnswersByQuizIDRow struct { CreatedAt sql.NullTime `db:"created_at" json:"created_at"` QuestionID int64 `db:"question_id" json:"question_id"` ID int64 `db:"id" json:"id"` - Questiontype interface{} `db:"questiontype" json:"questiontype"` + Questiontype string `db:"questiontype" json:"questiontype"` Qid uuid.NullUUID `db:"qid" json:"qid"` } diff --git a/repository/answer/answer.go b/repository/answer/answer.go index 17dace8..4fb7d48 100644 --- a/repository/answer/answer.go +++ b/repository/answer/answer.go @@ -84,8 +84,8 @@ func (r *AnswerRepository) GetAllAnswersByQuizID(ctx context.Context, session st } for _, row := range rows { - - if row.Questiontype.(string) == model.TypeFile { + if row.Questiontype == model.TypeFile { + fmt.Println("GALL", row.Qid, row.QuestionID, row.Content) fileURL, err := r.answerMinio.GetAnswerURL(ctx, row.Qid.UUID.String(), row.QuestionID, row.Content.String) if err != nil { fmt.Println("GetAnswerURL dal answer minio answer", err)