|
@ -24,6 +24,15 @@ func New(db DBTX) *Queries { |
|
|
func Prepare(ctx context.Context, db DBTX) (*Queries, error) { |
|
|
func Prepare(ctx context.Context, db DBTX) (*Queries, error) { |
|
|
q := Queries{db: db} |
|
|
q := Queries{db: db} |
|
|
var err error |
|
|
var err error |
|
|
|
|
|
if q.deleteAllScopeMembersStmt, err = db.PrepareContext(ctx, deleteAllScopeMembers); err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("error preparing query DeleteAllScopeMembers: %w", err) |
|
|
|
|
|
} |
|
|
|
|
|
if q.deleteScopeStmt, err = db.PrepareContext(ctx, deleteScope); err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("error preparing query DeleteScope: %w", err) |
|
|
|
|
|
} |
|
|
|
|
|
if q.deleteScopeMemberStmt, err = db.PrepareContext(ctx, deleteScopeMember); err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("error preparing query DeleteScopeMember: %w", err) |
|
|
|
|
|
} |
|
|
if q.getScopeStmt, err = db.PrepareContext(ctx, getScope); err != nil { |
|
|
if q.getScopeStmt, err = db.PrepareContext(ctx, getScope); err != nil { |
|
|
return nil, fmt.Errorf("error preparing query GetScope: %w", err) |
|
|
return nil, fmt.Errorf("error preparing query GetScope: %w", err) |
|
|
} |
|
|
} |
|
@ -33,6 +42,9 @@ func Prepare(ctx context.Context, db DBTX) (*Queries, error) { |
|
|
if q.getScopeWithDisplayNameStmt, err = db.PrepareContext(ctx, getScopeWithDisplayName); err != nil { |
|
|
if q.getScopeWithDisplayNameStmt, err = db.PrepareContext(ctx, getScopeWithDisplayName); err != nil { |
|
|
return nil, fmt.Errorf("error preparing query GetScopeWithDisplayName: %w", err) |
|
|
return nil, fmt.Errorf("error preparing query GetScopeWithDisplayName: %w", err) |
|
|
} |
|
|
} |
|
|
|
|
|
if q.insertScopeStmt, err = db.PrepareContext(ctx, insertScope); err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("error preparing query InsertScope: %w", err) |
|
|
|
|
|
} |
|
|
if q.listProjectEntriesStmt, err = db.PrepareContext(ctx, listProjectEntries); err != nil { |
|
|
if q.listProjectEntriesStmt, err = db.PrepareContext(ctx, listProjectEntries); err != nil { |
|
|
return nil, fmt.Errorf("error preparing query ListProjectEntries: %w", err) |
|
|
return nil, fmt.Errorf("error preparing query ListProjectEntries: %w", err) |
|
|
} |
|
|
} |
|
@ -48,11 +60,32 @@ func Prepare(ctx context.Context, db DBTX) (*Queries, error) { |
|
|
if q.listStatsStmt, err = db.PrepareContext(ctx, listStats); err != nil { |
|
|
if q.listStatsStmt, err = db.PrepareContext(ctx, listStats); err != nil { |
|
|
return nil, fmt.Errorf("error preparing query ListStats: %w", err) |
|
|
return nil, fmt.Errorf("error preparing query ListStats: %w", err) |
|
|
} |
|
|
} |
|
|
|
|
|
if q.updateScopeStmt, err = db.PrepareContext(ctx, updateScope); err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("error preparing query UpdateScope: %w", err) |
|
|
|
|
|
} |
|
|
|
|
|
if q.updateScopeMemberStmt, err = db.PrepareContext(ctx, updateScopeMember); err != nil { |
|
|
|
|
|
return nil, fmt.Errorf("error preparing query UpdateScopeMember: %w", err) |
|
|
|
|
|
} |
|
|
return &q, nil |
|
|
return &q, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (q *Queries) Close() error { |
|
|
func (q *Queries) Close() error { |
|
|
var err error |
|
|
var err error |
|
|
|
|
|
if q.deleteAllScopeMembersStmt != nil { |
|
|
|
|
|
if cerr := q.deleteAllScopeMembersStmt.Close(); cerr != nil { |
|
|
|
|
|
err = fmt.Errorf("error closing deleteAllScopeMembersStmt: %w", cerr) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if q.deleteScopeStmt != nil { |
|
|
|
|
|
if cerr := q.deleteScopeStmt.Close(); cerr != nil { |
|
|
|
|
|
err = fmt.Errorf("error closing deleteScopeStmt: %w", cerr) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if q.deleteScopeMemberStmt != nil { |
|
|
|
|
|
if cerr := q.deleteScopeMemberStmt.Close(); cerr != nil { |
|
|
|
|
|
err = fmt.Errorf("error closing deleteScopeMemberStmt: %w", cerr) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if q.getScopeStmt != nil { |
|
|
if q.getScopeStmt != nil { |
|
|
if cerr := q.getScopeStmt.Close(); cerr != nil { |
|
|
if cerr := q.getScopeStmt.Close(); cerr != nil { |
|
|
err = fmt.Errorf("error closing getScopeStmt: %w", cerr) |
|
|
err = fmt.Errorf("error closing getScopeStmt: %w", cerr) |
|
@ -68,6 +101,11 @@ func (q *Queries) Close() error { |
|
|
err = fmt.Errorf("error closing getScopeWithDisplayNameStmt: %w", cerr) |
|
|
err = fmt.Errorf("error closing getScopeWithDisplayNameStmt: %w", cerr) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if q.insertScopeStmt != nil { |
|
|
|
|
|
if cerr := q.insertScopeStmt.Close(); cerr != nil { |
|
|
|
|
|
err = fmt.Errorf("error closing insertScopeStmt: %w", cerr) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if q.listProjectEntriesStmt != nil { |
|
|
if q.listProjectEntriesStmt != nil { |
|
|
if cerr := q.listProjectEntriesStmt.Close(); cerr != nil { |
|
|
if cerr := q.listProjectEntriesStmt.Close(); cerr != nil { |
|
|
err = fmt.Errorf("error closing listProjectEntriesStmt: %w", cerr) |
|
|
err = fmt.Errorf("error closing listProjectEntriesStmt: %w", cerr) |
|
@ -93,6 +131,16 @@ func (q *Queries) Close() error { |
|
|
err = fmt.Errorf("error closing listStatsStmt: %w", cerr) |
|
|
err = fmt.Errorf("error closing listStatsStmt: %w", cerr) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if q.updateScopeStmt != nil { |
|
|
|
|
|
if cerr := q.updateScopeStmt.Close(); cerr != nil { |
|
|
|
|
|
err = fmt.Errorf("error closing updateScopeStmt: %w", cerr) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if q.updateScopeMemberStmt != nil { |
|
|
|
|
|
if cerr := q.updateScopeMemberStmt.Close(); cerr != nil { |
|
|
|
|
|
err = fmt.Errorf("error closing updateScopeMemberStmt: %w", cerr) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -132,27 +180,39 @@ func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, ar |
|
|
type Queries struct { |
|
|
type Queries struct { |
|
|
db DBTX |
|
|
db DBTX |
|
|
tx *sql.Tx |
|
|
tx *sql.Tx |
|
|
|
|
|
deleteAllScopeMembersStmt *sql.Stmt |
|
|
|
|
|
deleteScopeStmt *sql.Stmt |
|
|
|
|
|
deleteScopeMemberStmt *sql.Stmt |
|
|
getScopeStmt *sql.Stmt |
|
|
getScopeStmt *sql.Stmt |
|
|
getScopeDisplayNameStmt *sql.Stmt |
|
|
getScopeDisplayNameStmt *sql.Stmt |
|
|
getScopeWithDisplayNameStmt *sql.Stmt |
|
|
getScopeWithDisplayNameStmt *sql.Stmt |
|
|
|
|
|
insertScopeStmt *sql.Stmt |
|
|
listProjectEntriesStmt *sql.Stmt |
|
|
listProjectEntriesStmt *sql.Stmt |
|
|
listScopeMembersStmt *sql.Stmt |
|
|
listScopeMembersStmt *sql.Stmt |
|
|
listScopesStmt *sql.Stmt |
|
|
listScopesStmt *sql.Stmt |
|
|
listScopesByUserStmt *sql.Stmt |
|
|
listScopesByUserStmt *sql.Stmt |
|
|
listStatsStmt *sql.Stmt |
|
|
listStatsStmt *sql.Stmt |
|
|
|
|
|
updateScopeStmt *sql.Stmt |
|
|
|
|
|
updateScopeMemberStmt *sql.Stmt |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (q *Queries) WithTx(tx *sql.Tx) *Queries { |
|
|
func (q *Queries) WithTx(tx *sql.Tx) *Queries { |
|
|
return &Queries{ |
|
|
return &Queries{ |
|
|
db: tx, |
|
|
db: tx, |
|
|
tx: tx, |
|
|
tx: tx, |
|
|
|
|
|
deleteAllScopeMembersStmt: q.deleteAllScopeMembersStmt, |
|
|
|
|
|
deleteScopeStmt: q.deleteScopeStmt, |
|
|
|
|
|
deleteScopeMemberStmt: q.deleteScopeMemberStmt, |
|
|
getScopeStmt: q.getScopeStmt, |
|
|
getScopeStmt: q.getScopeStmt, |
|
|
getScopeDisplayNameStmt: q.getScopeDisplayNameStmt, |
|
|
getScopeDisplayNameStmt: q.getScopeDisplayNameStmt, |
|
|
getScopeWithDisplayNameStmt: q.getScopeWithDisplayNameStmt, |
|
|
getScopeWithDisplayNameStmt: q.getScopeWithDisplayNameStmt, |
|
|
|
|
|
insertScopeStmt: q.insertScopeStmt, |
|
|
listProjectEntriesStmt: q.listProjectEntriesStmt, |
|
|
listProjectEntriesStmt: q.listProjectEntriesStmt, |
|
|
listScopeMembersStmt: q.listScopeMembersStmt, |
|
|
listScopeMembersStmt: q.listScopeMembersStmt, |
|
|
listScopesStmt: q.listScopesStmt, |
|
|
listScopesStmt: q.listScopesStmt, |
|
|
listScopesByUserStmt: q.listScopesByUserStmt, |
|
|
listScopesByUserStmt: q.listScopesByUserStmt, |
|
|
listStatsStmt: q.listStatsStmt, |
|
|
listStatsStmt: q.listStatsStmt, |
|
|
|
|
|
updateScopeStmt: q.updateScopeStmt, |
|
|
|
|
|
updateScopeMemberStmt: q.updateScopeMemberStmt, |
|
|
} |
|
|
} |
|
|
} |
|
|
} |