|
|
@@ -6,6 +6,7 @@ package storage // import "miniflux.app/v2/internal/storage"
|
|
|
import (
|
|
|
"database/sql"
|
|
|
"fmt"
|
|
|
+ "strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
|
|
@@ -60,28 +61,28 @@ func (e *EntryQueryBuilder) WithStarred(starred bool) *EntryQueryBuilder {
|
|
|
|
|
|
// BeforeChangedDate adds a condition < changed_at
|
|
|
func (e *EntryQueryBuilder) BeforeChangedDate(date time.Time) *EntryQueryBuilder {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.changed_at < $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.changed_at < $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, date)
|
|
|
return e
|
|
|
}
|
|
|
|
|
|
// AfterChangedDate adds a condition > changed_at
|
|
|
func (e *EntryQueryBuilder) AfterChangedDate(date time.Time) *EntryQueryBuilder {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.changed_at > $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.changed_at > $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, date)
|
|
|
return e
|
|
|
}
|
|
|
|
|
|
// BeforePublishedDate adds a condition < published_at
|
|
|
func (e *EntryQueryBuilder) BeforePublishedDate(date time.Time) *EntryQueryBuilder {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.published_at < $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.published_at < $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, date)
|
|
|
return e
|
|
|
}
|
|
|
|
|
|
// AfterPublishedDate adds a condition > published_at
|
|
|
func (e *EntryQueryBuilder) AfterPublishedDate(date time.Time) *EntryQueryBuilder {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.published_at > $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.published_at > $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, date)
|
|
|
return e
|
|
|
}
|
|
|
@@ -89,7 +90,7 @@ func (e *EntryQueryBuilder) AfterPublishedDate(date time.Time) *EntryQueryBuilde
|
|
|
// BeforeEntryID adds a condition < entryID.
|
|
|
func (e *EntryQueryBuilder) BeforeEntryID(entryID int64) *EntryQueryBuilder {
|
|
|
if entryID != 0 {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.id < $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.id < $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, entryID)
|
|
|
}
|
|
|
return e
|
|
|
@@ -98,7 +99,7 @@ func (e *EntryQueryBuilder) BeforeEntryID(entryID int64) *EntryQueryBuilder {
|
|
|
// AfterEntryID adds a condition > entryID.
|
|
|
func (e *EntryQueryBuilder) AfterEntryID(entryID int64) *EntryQueryBuilder {
|
|
|
if entryID != 0 {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.id > $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.id > $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, entryID)
|
|
|
}
|
|
|
return e
|
|
|
@@ -114,7 +115,7 @@ func (e *EntryQueryBuilder) WithEntryIDs(entryIDs []int64) *EntryQueryBuilder {
|
|
|
// WithEntryID filter by entry ID.
|
|
|
func (e *EntryQueryBuilder) WithEntryID(entryID int64) *EntryQueryBuilder {
|
|
|
if entryID != 0 {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.id = $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.id = $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, entryID)
|
|
|
}
|
|
|
return e
|
|
|
@@ -123,7 +124,7 @@ func (e *EntryQueryBuilder) WithEntryID(entryID int64) *EntryQueryBuilder {
|
|
|
// WithFeedID filter by feed ID.
|
|
|
func (e *EntryQueryBuilder) WithFeedID(feedID int64) *EntryQueryBuilder {
|
|
|
if feedID > 0 {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.feed_id = $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.feed_id = $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, feedID)
|
|
|
}
|
|
|
return e
|
|
|
@@ -132,7 +133,7 @@ func (e *EntryQueryBuilder) WithFeedID(feedID int64) *EntryQueryBuilder {
|
|
|
// WithCategoryID filter by category ID.
|
|
|
func (e *EntryQueryBuilder) WithCategoryID(categoryID int64) *EntryQueryBuilder {
|
|
|
if categoryID > 0 {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("f.category_id = $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "f.category_id = $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, categoryID)
|
|
|
}
|
|
|
return e
|
|
|
@@ -141,7 +142,7 @@ func (e *EntryQueryBuilder) WithCategoryID(categoryID int64) *EntryQueryBuilder
|
|
|
// WithStatus filter by entry status.
|
|
|
func (e *EntryQueryBuilder) WithStatus(status string) *EntryQueryBuilder {
|
|
|
if status != "" {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.status = $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.status = $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, status)
|
|
|
}
|
|
|
return e
|
|
|
@@ -170,7 +171,7 @@ func (e *EntryQueryBuilder) WithTags(tags []string) *EntryQueryBuilder {
|
|
|
// WithoutStatus set the entry status that should not be returned.
|
|
|
func (e *EntryQueryBuilder) WithoutStatus(status string) *EntryQueryBuilder {
|
|
|
if status != "" {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.status <> $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.status <> $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, status)
|
|
|
}
|
|
|
return e
|
|
|
@@ -178,7 +179,7 @@ func (e *EntryQueryBuilder) WithoutStatus(status string) *EntryQueryBuilder {
|
|
|
|
|
|
// WithShareCode set the entry share code.
|
|
|
func (e *EntryQueryBuilder) WithShareCode(shareCode string) *EntryQueryBuilder {
|
|
|
- e.conditions = append(e.conditions, fmt.Sprintf("e.share_code = $%d", len(e.args)+1))
|
|
|
+ e.conditions = append(e.conditions, "e.share_code = $"+strconv.Itoa(len(e.args)+1))
|
|
|
e.args = append(e.args, shareCode)
|
|
|
return e
|
|
|
}
|
|
|
@@ -454,11 +455,11 @@ func (e *EntryQueryBuilder) buildSorting() string {
|
|
|
}
|
|
|
|
|
|
if e.limit > 0 {
|
|
|
- parts += fmt.Sprintf(" LIMIT %d", e.limit)
|
|
|
+ parts += " LIMIT " + strconv.Itoa(e.limit)
|
|
|
}
|
|
|
|
|
|
if e.offset > 0 {
|
|
|
- parts += fmt.Sprintf(" OFFSET %d", e.offset)
|
|
|
+ parts += " OFFSET " + strconv.Itoa(e.offset)
|
|
|
}
|
|
|
|
|
|
return parts
|