Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
fix: memo filter for postgres
Johnny3cc0e255cee1
diff --git a/store/db/postgres/memo_filter.go b/store/db/postgres/memo_filter.goindex b405d5dc3..f9e66929f 100644--- a/store/db/postgres/memo_filter.go+++ b/store/db/postgres/memo_filter.go@@ -160,7 +160,7 @@ func (d *DB) ConvertExprToSQL(ctx *filter.ConvertContext, expr *exprv1.Expr) errsubcodition := []string{}args := []any{}for _, v := range values {- subcodition, args = append(subcodition, fmt.Sprintf(`memo.payload->'tags' @> %s::jsonb`, placeholder(len(ctx.Args)+ctx.ArgsOffset+len(args)+1))), append(args, []any{v})+ subcodition, args = append(subcodition, fmt.Sprintf(`memo.payload->'tags' @> jsonb_build_array(%s)`, placeholder(len(ctx.Args)+ctx.ArgsOffset+len(args)+1))), append(args, v)}if len(subcodition) == 1 {if _, err := ctx.Buffer.WriteString(subcodition[0]); err != nil {diff --git a/store/db/postgres/memo_filter_test.go b/store/db/postgres/memo_filter_test.goindex 1fb20e30a..98cd98744 100644--- a/store/db/postgres/memo_filter_test.go+++ b/store/db/postgres/memo_filter_test.go@@ -16,13 +16,13 @@ func TestRestoreExprToSQL(t *testing.T) {}{{filter: `tag in ["tag1", "tag2"]`,- want: "(memo.payload->'tags' @> $1::jsonb OR memo.payload->'tags' @> $2::jsonb)",- args: []any{[]any{"tag1"}, []any{"tag2"}},+ want: "(memo.payload->'tags' @> jsonb_build_array($1) OR memo.payload->'tags' @> jsonb_build_array($2))",+ args: []any{"tag1", "tag2"},},{filter: `!(tag in ["tag1", "tag2"])`,- want: `NOT ((memo.payload->'tags' @> $1::jsonb OR memo.payload->'tags' @> $2::jsonb))`,- args: []any{[]any{"tag1"}, []any{"tag2"}},+ want: `NOT ((memo.payload->'tags' @> jsonb_build_array($1) OR memo.payload->'tags' @> jsonb_build_array($2)))`,+ args: []any{"tag1", "tag2"},},{filter: `content.contains("memos")`,@@ -46,8 +46,8 @@ func TestRestoreExprToSQL(t *testing.T) {},{filter: `tag in ['tag1'] || content.contains('hello')`,- want: "(memo.payload->'tags' @> $1::jsonb OR memo.content ILIKE $2)",- args: []any{[]any{"tag1"}, "%hello%"},+ want: "(memo.payload->'tags' @> jsonb_build_array($1) OR memo.content ILIKE $2)",+ args: []any{"tag1", "%hello%"},},{filter: `1`,