sqlcgen

package
v1.99.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchUpsertRelationshipsParams

type BatchUpsertRelationshipsParams struct {
	Subjects []pgtype.UUID
	Objects  []pgtype.UUID
	Kinds    []int32
	Roles    []pgtype.UUID
	Granters []pgtype.UUID
}

type CountGrantedObjectsParams added in v1.18.0

type CountGrantedObjectsParams struct {
	Subject pgtype.UUID
	Role    pgtype.UUID
	Objects []pgtype.UUID
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteRelationshipsParams added in v1.33.0

type DeleteRelationshipsParams struct {
	Subjects []pgtype.UUID
	Objects  []pgtype.UUID
	Kinds    []int32
}

type LookupRelationshipsByOrgParams added in v1.27.0

type LookupRelationshipsByOrgParams struct {
	OriginID     string
	Objects      []pgtype.UUID
	Kinds        []int32
	Roles        []pgtype.UUID
	UseCursor    bool
	AfterSubject pgtype.UUID
	AfterObject  pgtype.UUID
	AfterKind    int32
	AfterRole    pgtype.UUID
	PageLimit    int32
}

type LookupRelationshipsByOrgRow added in v1.27.0

type LookupRelationshipsByOrgRow struct {
	Subject          pgtype.UUID
	Object           pgtype.UUID
	Kind             int32
	EdgeType         int32
	Role             pgtype.UUID
	CreatedAt        pgtype.Timestamptz
	SubjectLocalID   string
	GrantedByLocalID pgtype.Text
}

type LookupRelationshipsBySubjectParams added in v1.49.0

type LookupRelationshipsBySubjectParams struct {
	Subject     pgtype.UUID
	Kinds       []int32
	Roles       []pgtype.UUID
	UseCursor   bool
	AfterObject pgtype.UUID
	AfterKind   int32
	PageLimit   int32
}

type Querier

type Querier interface {
	BatchUpsertRelationships(ctx context.Context, arg BatchUpsertRelationshipsParams) ([]Relationship, error)
	CountGrantedObjects(ctx context.Context, arg CountGrantedObjectsParams) (int64, error)
	DeleteRelationships(ctx context.Context, arg DeleteRelationshipsParams) error
	// origin = 1 is relationships.v1.Origin ORIGIN_ORGANIZATION; org scoping is by
	// the subject's local identity in that org.
	//
	// Both identities joins and the cursor assume one identities row per principal
	// per org, which identity resolution guarantees today. Principals are moving to
	// several identities per org; this query must change first (see the storage
	// schema in docs/relationships-api.md, gitlab-org/gitlab#635812).
	LookupRelationshipsByOrg(ctx context.Context, arg LookupRelationshipsByOrgParams) ([]LookupRelationshipsByOrgRow, error)
	// edge_type = 1 plus the fixed subject means relationships_direct_grant_unique
	// already makes (object, kind) unique per row, so role breaks no ties and is
	// left out of the order/cursor (unlike LookupRelationshipsByOrg, which scans
	// multiple subjects and does need it).
	LookupRelationshipsBySubject(ctx context.Context, arg LookupRelationshipsBySubjectParams) ([]Relationship, error)
	ReadRelationships(ctx context.Context, arg ReadRelationshipsParams) ([]Relationship, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) BatchUpsertRelationships

func (q *Queries) BatchUpsertRelationships(ctx context.Context, arg BatchUpsertRelationshipsParams) ([]Relationship, error)

func (*Queries) CountGrantedObjects added in v1.18.0

func (q *Queries) CountGrantedObjects(ctx context.Context, arg CountGrantedObjectsParams) (int64, error)

func (*Queries) DeleteRelationships added in v1.33.0

func (q *Queries) DeleteRelationships(ctx context.Context, arg DeleteRelationshipsParams) error

func (*Queries) LookupRelationshipsByOrg added in v1.27.0

func (q *Queries) LookupRelationshipsByOrg(ctx context.Context, arg LookupRelationshipsByOrgParams) ([]LookupRelationshipsByOrgRow, error)

origin = 1 is relationships.v1.Origin ORIGIN_ORGANIZATION; org scoping is by the subject's local identity in that org.

Both identities joins and the cursor assume one identities row per principal per org, which identity resolution guarantees today. Principals are moving to several identities per org; this query must change first (see the storage schema in docs/relationships-api.md, gitlab-org/gitlab#635812).

func (*Queries) LookupRelationshipsBySubject added in v1.49.0

func (q *Queries) LookupRelationshipsBySubject(ctx context.Context, arg LookupRelationshipsBySubjectParams) ([]Relationship, error)

edge_type = 1 plus the fixed subject means relationships_direct_grant_unique already makes (object, kind) unique per row, so role breaks no ties and is left out of the order/cursor (unlike LookupRelationshipsByOrg, which scans multiple subjects and does need it).

func (*Queries) ReadRelationships added in v1.16.0

func (q *Queries) ReadRelationships(ctx context.Context, arg ReadRelationshipsParams) ([]Relationship, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ReadRelationshipsParams added in v1.16.0

type ReadRelationshipsParams struct {
	Subject pgtype.UUID
	Objects []pgtype.UUID
	Kinds   []int32
}

type Relationship

type Relationship struct {
	Subject   pgtype.UUID
	Object    pgtype.UUID
	Kind      int32
	EdgeType  int32
	Role      pgtype.UUID
	CreatedAt pgtype.Timestamptz
	GrantedBy pgtype.UUID
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL