Files
grafana/pkg/registry/apis/iam/legacy/team_bindings_query.sql
Mihai Doarna 7d88b0130c IAM: Generate a unique name for a new TeamBinding object (#112525)
* generate a unique name for TeamBinding and store it in the uid column

* generate testdata

* fix team binding name
2025-10-21 15:01:49 +03:00

16 lines
616 B
SQL

SELECT tm.id as id, tm.uid as uid, t.uid as team_uid, t.id as team_id, u.uid as user_uid, u.id as user_id, tm.created, tm.updated, tm.permission, tm.external
FROM {{ .Ident .TeamMemberTable }} tm
INNER JOIN {{ .Ident .TeamTable }} t ON tm.team_id = t.id
INNER JOIN {{ .Ident .UserTable }} u ON tm.user_id = u.id
WHERE
tm.org_id = {{ .Arg .Query.OrgID}}
{{ if .Query.UID }}
AND tm.uid = {{ .Arg .Query.UID }}
{{ end }}
{{- if .Query.Pagination.Continue }}
AND tm.id >= {{ .Arg .Query.Pagination.Continue }}
{{- end }}
AND NOT tm.external
ORDER BY t.id ASC
LIMIT {{ .Arg .Query.Pagination.Limit }};