You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.7 KiB

1 year ago
  1. // Code generated by sqlc. DO NOT EDIT.
  2. // versions:
  3. // sqlc v1.13.0
  4. package mysqlgen
  5. import (
  6. "context"
  7. "database/sql"
  8. "fmt"
  9. )
  10. type DBTX interface {
  11. ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
  12. PrepareContext(context.Context, string) (*sql.Stmt, error)
  13. QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
  14. QueryRowContext(context.Context, string, ...interface{}) *sql.Row
  15. }
  16. func New(db DBTX) *Queries {
  17. return &Queries{db: db}
  18. }
  19. func Prepare(ctx context.Context, db DBTX) (*Queries, error) {
  20. q := Queries{db: db}
  21. var err error
  22. if q.deleteTagStmt, err = db.PrepareContext(ctx, deleteTag); err != nil {
  23. return nil, fmt.Errorf("error preparing query DeleteTag: %w", err)
  24. }
  25. if q.findTagStmt, err = db.PrepareContext(ctx, findTag); err != nil {
  26. return nil, fmt.Errorf("error preparing query FindTag: %w", err)
  27. }
  28. if q.listListedTagsStmt, err = db.PrepareContext(ctx, listListedTags); err != nil {
  29. return nil, fmt.Errorf("error preparing query ListListedTags: %w", err)
  30. }
  31. if q.listTagsStmt, err = db.PrepareContext(ctx, listTags); err != nil {
  32. return nil, fmt.Errorf("error preparing query ListTags: %w", err)
  33. }
  34. if q.replaceTagStmt, err = db.PrepareContext(ctx, replaceTag); err != nil {
  35. return nil, fmt.Errorf("error preparing query ReplaceTag: %w", err)
  36. }
  37. return &q, nil
  38. }
  39. func (q *Queries) Close() error {
  40. var err error
  41. if q.deleteTagStmt != nil {
  42. if cerr := q.deleteTagStmt.Close(); cerr != nil {
  43. err = fmt.Errorf("error closing deleteTagStmt: %w", cerr)
  44. }
  45. }
  46. if q.findTagStmt != nil {
  47. if cerr := q.findTagStmt.Close(); cerr != nil {
  48. err = fmt.Errorf("error closing findTagStmt: %w", cerr)
  49. }
  50. }
  51. if q.listListedTagsStmt != nil {
  52. if cerr := q.listListedTagsStmt.Close(); cerr != nil {
  53. err = fmt.Errorf("error closing listListedTagsStmt: %w", cerr)
  54. }
  55. }
  56. if q.listTagsStmt != nil {
  57. if cerr := q.listTagsStmt.Close(); cerr != nil {
  58. err = fmt.Errorf("error closing listTagsStmt: %w", cerr)
  59. }
  60. }
  61. if q.replaceTagStmt != nil {
  62. if cerr := q.replaceTagStmt.Close(); cerr != nil {
  63. err = fmt.Errorf("error closing replaceTagStmt: %w", cerr)
  64. }
  65. }
  66. return err
  67. }
  68. func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) {
  69. switch {
  70. case stmt != nil && q.tx != nil:
  71. return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...)
  72. case stmt != nil:
  73. return stmt.ExecContext(ctx, args...)
  74. default:
  75. return q.db.ExecContext(ctx, query, args...)
  76. }
  77. }
  78. func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) {
  79. switch {
  80. case stmt != nil && q.tx != nil:
  81. return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...)
  82. case stmt != nil:
  83. return stmt.QueryContext(ctx, args...)
  84. default:
  85. return q.db.QueryContext(ctx, query, args...)
  86. }
  87. }
  88. func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row {
  89. switch {
  90. case stmt != nil && q.tx != nil:
  91. return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)
  92. case stmt != nil:
  93. return stmt.QueryRowContext(ctx, args...)
  94. default:
  95. return q.db.QueryRowContext(ctx, query, args...)
  96. }
  97. }
  98. type Queries struct {
  99. db DBTX
  100. tx *sql.Tx
  101. deleteTagStmt *sql.Stmt
  102. findTagStmt *sql.Stmt
  103. listListedTagsStmt *sql.Stmt
  104. listTagsStmt *sql.Stmt
  105. replaceTagStmt *sql.Stmt
  106. }
  107. func (q *Queries) WithTx(tx *sql.Tx) *Queries {
  108. return &Queries{
  109. db: tx,
  110. tx: tx,
  111. deleteTagStmt: q.deleteTagStmt,
  112. findTagStmt: q.findTagStmt,
  113. listListedTagsStmt: q.listListedTagsStmt,
  114. listTagsStmt: q.listTagsStmt,
  115. replaceTagStmt: q.replaceTagStmt,
  116. }
  117. }