chore: fix postgres driver

This commit is contained in:
Steven
2023-12-17 20:07:25 +08:00
parent a7d48e8059
commit 4c66edc170
18 changed files with 104 additions and 200 deletions

View File

@ -2,7 +2,6 @@ package postgres
import (
"context"
"fmt"
"strings"
"github.com/yourselfhosted/slash/store"
@ -38,10 +37,10 @@ func (d *DB) CreateActivity(ctx context.Context, create *store.Activity) (*store
func (d *DB) ListActivities(ctx context.Context, find *store.FindActivity) ([]*store.Activity, error) {
where, args := []string{"1 = 1"}, []any{}
if find.Type != "" {
where, args = append(where, "type = $"+fmt.Sprint(len(args)+1)), append(args, find.Type.String())
where, args = append(where, "type = "+placeholder(len(args)+1)), append(args, find.Type.String())
}
if find.Level != "" {
where, args = append(where, "level = $"+fmt.Sprint(len(args)+1)), append(args, find.Level.String())
where, args = append(where, "level = "+placeholder(len(args)+1)), append(args, find.Level.String())
}
if find.Where != nil {
where = append(where, find.Where...)