MCPcopy Create free account
hub / github.com/PostHog/duckgres / internalCompatRelationNamesSQL

Function internalCompatRelationNamesSQL

server/sessionmeta/sessionmeta.go:220–238  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

218func (p *MetadataAccessPolicy) schemaPredicate(schemaExpression string) string {
219 if p == nil {
220 return "TRUE"
221 }
222 values := append([]string(nil), p.AllowedSchemas...)
223 for _, relation := range p.AllowedRelations {
224 if schema, _, ok := strings.Cut(relation, "."); ok {
225 values = append(values, schema)
226 }
227 }
228 values = normalizedSQLValues(values)
229 if len(values) == 0 {
230 return "FALSE"
231 }
232 return fmt.Sprintf("lower(%s) IN (%s)", schemaExpression, quotedSQLValues(values))
233}
234
235func normalizedSQLValues(values []string) []string {
236 seen := make(map[string]struct{}, len(values))
237 for _, value := range values {
238 value = strings.ToLower(strings.TrimSpace(value))
239 if value != "" {
240 seen[value] = struct{}{}
241 }

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected