Some checks failed
Backend Tests / Static Checks (push) Has been cancelled
Backend Tests / Tests (other) (push) Has been cancelled
Backend Tests / Tests (plugin) (push) Has been cancelled
Backend Tests / Tests (server) (push) Has been cancelled
Backend Tests / Tests (store) (push) Has been cancelled
Build Canary Image / build-frontend (push) Has been cancelled
Build Canary Image / build-push (linux/amd64) (push) Has been cancelled
Build Canary Image / build-push (linux/arm64) (push) Has been cancelled
Build Canary Image / merge (push) Has been cancelled
Frontend Tests / Lint (push) Has been cancelled
Frontend Tests / Build (push) Has been cancelled
Proto Linter / Lint Protos (push) Has been cancelled
26 lines
647 B
Go
26 lines
647 B
Go
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
|
|
}
|