// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.13.0 package mysqlgen import ( "context" "database/sql" "fmt" ) type DBTX interface { ExecContext(context.Context, string, ...interface{}) (sql.Result, error) PrepareContext(context.Context, string) (*sql.Stmt, error) QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error) QueryRowContext(context.Context, string, ...interface{}) *sql.Row } func New(db DBTX) *Queries { return &Queries{db: db} } func Prepare(ctx context.Context, db DBTX) (*Queries, error) { q := Queries{db: db} var err error if q.deleteDeviceAliasStmt, err = db.PrepareContext(ctx, deleteDeviceAlias); err != nil { return nil, fmt.Errorf("error preparing query DeleteDeviceAlias: %w", err) } if q.deleteDeviceAliasByIDStmt, err = db.PrepareContext(ctx, deleteDeviceAliasByID); err != nil { return nil, fmt.Errorf("error preparing query DeleteDeviceAliasByID: %w", err) } if q.deleteDeviceAliasByIDLikeStmt, err = db.PrepareContext(ctx, deleteDeviceAliasByIDLike); err != nil { return nil, fmt.Errorf("error preparing query DeleteDeviceAliasByIDLike: %w", err) } if q.deleteDeviceAssignmentStmt, err = db.PrepareContext(ctx, deleteDeviceAssignment); err != nil { return nil, fmt.Errorf("error preparing query DeleteDeviceAssignment: %w", err) } if q.deleteDeviceAuthStmt, err = db.PrepareContext(ctx, deleteDeviceAuth); err != nil { return nil, fmt.Errorf("error preparing query DeleteDeviceAuth: %w", err) } if q.deleteDeviceInfoStmt, err = db.PrepareContext(ctx, deleteDeviceInfo); err != nil { return nil, fmt.Errorf("error preparing query DeleteDeviceInfo: %w", err) } if q.deleteDeviceInfoByIDStmt, err = db.PrepareContext(ctx, deleteDeviceInfoByID); err != nil { return nil, fmt.Errorf("error preparing query DeleteDeviceInfoByID: %w", err) } if q.deleteDeviceInfoLikeStmt, err = db.PrepareContext(ctx, deleteDeviceInfoLike); err != nil { return nil, fmt.Errorf("error preparing query DeleteDeviceInfoLike: %w", err) } if q.deleteScriptStmt, err = db.PrepareContext(ctx, deleteScript); err != nil { return nil, fmt.Errorf("error preparing query DeleteScript: %w", err) } if q.deleteScriptTriggerStmt, err = db.PrepareContext(ctx, deleteScriptTrigger); err != nil { return nil, fmt.Errorf("error preparing query DeleteScriptTrigger: %w", err) } if q.insertDeviceAliasStmt, err = db.PrepareContext(ctx, insertDeviceAlias); err != nil { return nil, fmt.Errorf("error preparing query InsertDeviceAlias: %w", err) } if q.listDeviceAliasesStmt, err = db.PrepareContext(ctx, listDeviceAliases); err != nil { return nil, fmt.Errorf("error preparing query ListDeviceAliases: %w", err) } if q.listDeviceAssignmentsStmt, err = db.PrepareContext(ctx, listDeviceAssignments); err != nil { return nil, fmt.Errorf("error preparing query ListDeviceAssignments: %w", err) } if q.listDeviceAuthStmt, err = db.PrepareContext(ctx, listDeviceAuth); err != nil { return nil, fmt.Errorf("error preparing query ListDeviceAuth: %w", err) } if q.listDeviceInfosStmt, err = db.PrepareContext(ctx, listDeviceInfos); err != nil { return nil, fmt.Errorf("error preparing query ListDeviceInfos: %w", err) } if q.listScriptTriggersStmt, err = db.PrepareContext(ctx, listScriptTriggers); err != nil { return nil, fmt.Errorf("error preparing query ListScriptTriggers: %w", err) } if q.listScriptVariablesStmt, err = db.PrepareContext(ctx, listScriptVariables); err != nil { return nil, fmt.Errorf("error preparing query ListScriptVariables: %w", err) } if q.listScriptsStmt, err = db.PrepareContext(ctx, listScripts); err != nil { return nil, fmt.Errorf("error preparing query ListScripts: %w", err) } if q.replaceDeviceAssignmentStmt, err = db.PrepareContext(ctx, replaceDeviceAssignment); err != nil { return nil, fmt.Errorf("error preparing query ReplaceDeviceAssignment: %w", err) } if q.replaceDeviceAuthStmt, err = db.PrepareContext(ctx, replaceDeviceAuth); err != nil { return nil, fmt.Errorf("error preparing query ReplaceDeviceAuth: %w", err) } if q.replaceDeviceInfoStmt, err = db.PrepareContext(ctx, replaceDeviceInfo); err != nil { return nil, fmt.Errorf("error preparing query ReplaceDeviceInfo: %w", err) } if q.replaceScriptTriggerStmt, err = db.PrepareContext(ctx, replaceScriptTrigger); err != nil { return nil, fmt.Errorf("error preparing query ReplaceScriptTrigger: %w", err) } if q.saveScriptStmt, err = db.PrepareContext(ctx, saveScript); err != nil { return nil, fmt.Errorf("error preparing query SaveScript: %w", err) } if q.updateScriptVariablesStmt, err = db.PrepareContext(ctx, updateScriptVariables); err != nil { return nil, fmt.Errorf("error preparing query UpdateScriptVariables: %w", err) } return &q, nil } func (q *Queries) Close() error { var err error if q.deleteDeviceAliasStmt != nil { if cerr := q.deleteDeviceAliasStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteDeviceAliasStmt: %w", cerr) } } if q.deleteDeviceAliasByIDStmt != nil { if cerr := q.deleteDeviceAliasByIDStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteDeviceAliasByIDStmt: %w", cerr) } } if q.deleteDeviceAliasByIDLikeStmt != nil { if cerr := q.deleteDeviceAliasByIDLikeStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteDeviceAliasByIDLikeStmt: %w", cerr) } } if q.deleteDeviceAssignmentStmt != nil { if cerr := q.deleteDeviceAssignmentStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteDeviceAssignmentStmt: %w", cerr) } } if q.deleteDeviceAuthStmt != nil { if cerr := q.deleteDeviceAuthStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteDeviceAuthStmt: %w", cerr) } } if q.deleteDeviceInfoStmt != nil { if cerr := q.deleteDeviceInfoStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteDeviceInfoStmt: %w", cerr) } } if q.deleteDeviceInfoByIDStmt != nil { if cerr := q.deleteDeviceInfoByIDStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteDeviceInfoByIDStmt: %w", cerr) } } if q.deleteDeviceInfoLikeStmt != nil { if cerr := q.deleteDeviceInfoLikeStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteDeviceInfoLikeStmt: %w", cerr) } } if q.deleteScriptStmt != nil { if cerr := q.deleteScriptStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteScriptStmt: %w", cerr) } } if q.deleteScriptTriggerStmt != nil { if cerr := q.deleteScriptTriggerStmt.Close(); cerr != nil { err = fmt.Errorf("error closing deleteScriptTriggerStmt: %w", cerr) } } if q.insertDeviceAliasStmt != nil { if cerr := q.insertDeviceAliasStmt.Close(); cerr != nil { err = fmt.Errorf("error closing insertDeviceAliasStmt: %w", cerr) } } if q.listDeviceAliasesStmt != nil { if cerr := q.listDeviceAliasesStmt.Close(); cerr != nil { err = fmt.Errorf("error closing listDeviceAliasesStmt: %w", cerr) } } if q.listDeviceAssignmentsStmt != nil { if cerr := q.listDeviceAssignmentsStmt.Close(); cerr != nil { err = fmt.Errorf("error closing listDeviceAssignmentsStmt: %w", cerr) } } if q.listDeviceAuthStmt != nil { if cerr := q.listDeviceAuthStmt.Close(); cerr != nil { err = fmt.Errorf("error closing listDeviceAuthStmt: %w", cerr) } } if q.listDeviceInfosStmt != nil { if cerr := q.listDeviceInfosStmt.Close(); cerr != nil { err = fmt.Errorf("error closing listDeviceInfosStmt: %w", cerr) } } if q.listScriptTriggersStmt != nil { if cerr := q.listScriptTriggersStmt.Close(); cerr != nil { err = fmt.Errorf("error closing listScriptTriggersStmt: %w", cerr) } } if q.listScriptVariablesStmt != nil { if cerr := q.listScriptVariablesStmt.Close(); cerr != nil { err = fmt.Errorf("error closing listScriptVariablesStmt: %w", cerr) } } if q.listScriptsStmt != nil { if cerr := q.listScriptsStmt.Close(); cerr != nil { err = fmt.Errorf("error closing listScriptsStmt: %w", cerr) } } if q.replaceDeviceAssignmentStmt != nil { if cerr := q.replaceDeviceAssignmentStmt.Close(); cerr != nil { err = fmt.Errorf("error closing replaceDeviceAssignmentStmt: %w", cerr) } } if q.replaceDeviceAuthStmt != nil { if cerr := q.replaceDeviceAuthStmt.Close(); cerr != nil { err = fmt.Errorf("error closing replaceDeviceAuthStmt: %w", cerr) } } if q.replaceDeviceInfoStmt != nil { if cerr := q.replaceDeviceInfoStmt.Close(); cerr != nil { err = fmt.Errorf("error closing replaceDeviceInfoStmt: %w", cerr) } } if q.replaceScriptTriggerStmt != nil { if cerr := q.replaceScriptTriggerStmt.Close(); cerr != nil { err = fmt.Errorf("error closing replaceScriptTriggerStmt: %w", cerr) } } if q.saveScriptStmt != nil { if cerr := q.saveScriptStmt.Close(); cerr != nil { err = fmt.Errorf("error closing saveScriptStmt: %w", cerr) } } if q.updateScriptVariablesStmt != nil { if cerr := q.updateScriptVariablesStmt.Close(); cerr != nil { err = fmt.Errorf("error closing updateScriptVariablesStmt: %w", cerr) } } return err } func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) { switch { case stmt != nil && q.tx != nil: return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...) case stmt != nil: return stmt.ExecContext(ctx, args...) default: return q.db.ExecContext(ctx, query, args...) } } func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) { switch { case stmt != nil && q.tx != nil: return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...) case stmt != nil: return stmt.QueryContext(ctx, args...) default: return q.db.QueryContext(ctx, query, args...) } } func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row { switch { case stmt != nil && q.tx != nil: return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...) case stmt != nil: return stmt.QueryRowContext(ctx, args...) default: return q.db.QueryRowContext(ctx, query, args...) } } type Queries struct { db DBTX tx *sql.Tx deleteDeviceAliasStmt *sql.Stmt deleteDeviceAliasByIDStmt *sql.Stmt deleteDeviceAliasByIDLikeStmt *sql.Stmt deleteDeviceAssignmentStmt *sql.Stmt deleteDeviceAuthStmt *sql.Stmt deleteDeviceInfoStmt *sql.Stmt deleteDeviceInfoByIDStmt *sql.Stmt deleteDeviceInfoLikeStmt *sql.Stmt deleteScriptStmt *sql.Stmt deleteScriptTriggerStmt *sql.Stmt insertDeviceAliasStmt *sql.Stmt listDeviceAliasesStmt *sql.Stmt listDeviceAssignmentsStmt *sql.Stmt listDeviceAuthStmt *sql.Stmt listDeviceInfosStmt *sql.Stmt listScriptTriggersStmt *sql.Stmt listScriptVariablesStmt *sql.Stmt listScriptsStmt *sql.Stmt replaceDeviceAssignmentStmt *sql.Stmt replaceDeviceAuthStmt *sql.Stmt replaceDeviceInfoStmt *sql.Stmt replaceScriptTriggerStmt *sql.Stmt saveScriptStmt *sql.Stmt updateScriptVariablesStmt *sql.Stmt } func (q *Queries) WithTx(tx *sql.Tx) *Queries { return &Queries{ db: tx, tx: tx, deleteDeviceAliasStmt: q.deleteDeviceAliasStmt, deleteDeviceAliasByIDStmt: q.deleteDeviceAliasByIDStmt, deleteDeviceAliasByIDLikeStmt: q.deleteDeviceAliasByIDLikeStmt, deleteDeviceAssignmentStmt: q.deleteDeviceAssignmentStmt, deleteDeviceAuthStmt: q.deleteDeviceAuthStmt, deleteDeviceInfoStmt: q.deleteDeviceInfoStmt, deleteDeviceInfoByIDStmt: q.deleteDeviceInfoByIDStmt, deleteDeviceInfoLikeStmt: q.deleteDeviceInfoLikeStmt, deleteScriptStmt: q.deleteScriptStmt, deleteScriptTriggerStmt: q.deleteScriptTriggerStmt, insertDeviceAliasStmt: q.insertDeviceAliasStmt, listDeviceAliasesStmt: q.listDeviceAliasesStmt, listDeviceAssignmentsStmt: q.listDeviceAssignmentsStmt, listDeviceAuthStmt: q.listDeviceAuthStmt, listDeviceInfosStmt: q.listDeviceInfosStmt, listScriptTriggersStmt: q.listScriptTriggersStmt, listScriptVariablesStmt: q.listScriptVariablesStmt, listScriptsStmt: q.listScriptsStmt, replaceDeviceAssignmentStmt: q.replaceDeviceAssignmentStmt, replaceDeviceAuthStmt: q.replaceDeviceAuthStmt, replaceDeviceInfoStmt: q.replaceDeviceInfoStmt, replaceScriptTriggerStmt: q.replaceScriptTriggerStmt, saveScriptStmt: q.saveScriptStmt, updateScriptVariablesStmt: q.updateScriptVariablesStmt, } }