mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
fix: ListTag not support omit params (#2366)
fix ListTag not support omit params
This commit is contained in:
@@ -18,7 +18,12 @@ func (d *DB) UpsertTag(ctx context.Context, upsert *store.Tag) (*store.Tag, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DB) ListTags(ctx context.Context, find *store.FindTag) ([]*store.Tag, error) {
|
func (d *DB) ListTags(ctx context.Context, find *store.FindTag) ([]*store.Tag, error) {
|
||||||
where, args := []string{"`creator_id` = ?"}, []any{find.CreatorID}
|
where, args := []string{"1 = 1"}, []any{}
|
||||||
|
|
||||||
|
if find.CreatorID != 0 {
|
||||||
|
where, args = append(where, "`creator_id` = ?"), append(args, find.CreatorID)
|
||||||
|
}
|
||||||
|
|
||||||
query := "SELECT `name`, `creator_id` FROM `tag` WHERE " + strings.Join(where, " AND ") + " ORDER BY name ASC"
|
query := "SELECT `name`, `creator_id` FROM `tag` WHERE " + strings.Join(where, " AND ") + " ORDER BY name ASC"
|
||||||
rows, err := d.db.QueryContext(ctx, query, args...)
|
rows, err := d.db.QueryContext(ctx, query, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -27,7 +27,12 @@ func (d *DB) UpsertTag(ctx context.Context, upsert *store.Tag) (*store.Tag, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *DB) ListTags(ctx context.Context, find *store.FindTag) ([]*store.Tag, error) {
|
func (d *DB) ListTags(ctx context.Context, find *store.FindTag) ([]*store.Tag, error) {
|
||||||
where, args := []string{"creator_id = ?"}, []any{find.CreatorID}
|
where, args := []string{"1 = 1"}, []any{}
|
||||||
|
|
||||||
|
if find.CreatorID != 0 {
|
||||||
|
where, args = append(where, "`creator_id` = ?"), append(args, find.CreatorID)
|
||||||
|
}
|
||||||
|
|
||||||
query := `
|
query := `
|
||||||
SELECT
|
SELECT
|
||||||
name,
|
name,
|
||||||
|
Reference in New Issue
Block a user