Skip to content

armgit / memos

Public Imported from GitHub
0

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.

647 B
Raw Blame
package filter

import (
	"context"
	"fmt"
)

// AppendConditions compiles the provided filters and appends the resulting SQL fragments and args.
func AppendConditions(ctx context.Context, engine *Engine, filters []string, dialect DialectName, where *[]string, args *[]any) error {
	for _, filterStr := range filters {
		stmt, err := engine.CompileToStatement(ctx, filterStr, RenderOptions{
			Dialect:           dialect,
			PlaceholderOffset: len(*args),
		})
		if err != nil {
			return err
		}
		if stmt.SQL == "" {
			continue
		}
		*where = append(*where, fmt.Sprintf("(%s)", stmt.SQL))
		*args = append(*args, stmt.Args...)
	}
	return nil
}