33 lines
386 B
Go
33 lines
386 B
Go
package authz
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
func BuildMSSQLPiyasaFilter(
|
|
ctx context.Context,
|
|
column string,
|
|
) string {
|
|
|
|
codes := GetPiyasaCodesFromCtx(ctx)
|
|
|
|
if len(codes) == 0 {
|
|
return "1=1"
|
|
|
|
}
|
|
|
|
var quoted []string
|
|
|
|
for _, c := range codes {
|
|
quoted = append(quoted, "'"+c+"'")
|
|
}
|
|
|
|
return fmt.Sprintf(
|
|
"%s IN (%s)",
|
|
column,
|
|
strings.Join(quoted, ","),
|
|
)
|
|
}
|