Skip to content

Commit

Permalink
db(questions): update for pg
Browse files Browse the repository at this point in the history
  • Loading branch information
wuhan005 committed Jan 12, 2024
1 parent 524e2ed commit 1b3740e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/db/questions.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func (db *questions) GetByUserID(ctx context.Context, userID uint, opts GetQuest
args := userID

if opts.FilterAnswered {
where = `user_id = ? AND answer <> ""`
where = `user_id = ? AND answer != ''`
}
if !opts.ShowPrivate {
where += ` AND is_private = false`
Expand All @@ -191,7 +191,7 @@ func (db *questions) GetByAskUserID(ctx context.Context, userID uint, opts GetQu
args := userID

if opts.FilterAnswered {
where = `asker_user_id = ? AND answer <> ""`
where = `asker_user_id = ? AND answer <> ''`
}
if !opts.ShowPrivate {
where += ` AND is_private = false`
Expand Down Expand Up @@ -242,7 +242,7 @@ type GetQuestionsCountOptions struct {
func (db *questions) Count(ctx context.Context, userID uint, opts GetQuestionsCountOptions) (int64, error) {
q := db.WithContext(ctx).Model(&Question{})
if opts.FilterAnswered {
q = q.Where(`user_id = ? AND answer <> ""`, userID)
q = q.Where(`user_id = ? AND answer <> ''`, userID)
} else {
q = q.Where(`user_id = ?`, userID)
}
Expand Down

0 comments on commit 1b3740e

Please sign in to comment.