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.

238 lines
9.0 KiB

2 years 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.deleteDeviceAliasStmt, err = db.PrepareContext(ctx, deleteDeviceAlias); err != nil {
  23. return nil, fmt.Errorf("error preparing query DeleteDeviceAlias: %w", err)
  24. }
  25. if q.deleteDeviceAliasByIDStmt, err = db.PrepareContext(ctx, deleteDeviceAliasByID); err != nil {
  26. return nil, fmt.Errorf("error preparing query DeleteDeviceAliasByID: %w", err)
  27. }
  28. if q.deleteDeviceAliasByIDLikeStmt, err = db.PrepareContext(ctx, deleteDeviceAliasByIDLike); err != nil {
  29. return nil, fmt.Errorf("error preparing query DeleteDeviceAliasByIDLike: %w", err)
  30. }
  31. if q.deleteDeviceAssignmentStmt, err = db.PrepareContext(ctx, deleteDeviceAssignment); err != nil {
  32. return nil, fmt.Errorf("error preparing query DeleteDeviceAssignment: %w", err)
  33. }
  34. if q.deleteDeviceAuthStmt, err = db.PrepareContext(ctx, deleteDeviceAuth); err != nil {
  35. return nil, fmt.Errorf("error preparing query DeleteDeviceAuth: %w", err)
  36. }
  37. if q.deleteDeviceInfoStmt, err = db.PrepareContext(ctx, deleteDeviceInfo); err != nil {
  38. return nil, fmt.Errorf("error preparing query DeleteDeviceInfo: %w", err)
  39. }
  40. if q.deleteDeviceInfoByIDStmt, err = db.PrepareContext(ctx, deleteDeviceInfoByID); err != nil {
  41. return nil, fmt.Errorf("error preparing query DeleteDeviceInfoByID: %w", err)
  42. }
  43. if q.deleteDeviceInfoLikeStmt, err = db.PrepareContext(ctx, deleteDeviceInfoLike); err != nil {
  44. return nil, fmt.Errorf("error preparing query DeleteDeviceInfoLike: %w", err)
  45. }
  46. if q.insertDeviceAliasStmt, err = db.PrepareContext(ctx, insertDeviceAlias); err != nil {
  47. return nil, fmt.Errorf("error preparing query InsertDeviceAlias: %w", err)
  48. }
  49. if q.listDeviceAliasesStmt, err = db.PrepareContext(ctx, listDeviceAliases); err != nil {
  50. return nil, fmt.Errorf("error preparing query ListDeviceAliases: %w", err)
  51. }
  52. if q.listDeviceAssignmentsStmt, err = db.PrepareContext(ctx, listDeviceAssignments); err != nil {
  53. return nil, fmt.Errorf("error preparing query ListDeviceAssignments: %w", err)
  54. }
  55. if q.listDeviceAuthStmt, err = db.PrepareContext(ctx, listDeviceAuth); err != nil {
  56. return nil, fmt.Errorf("error preparing query ListDeviceAuth: %w", err)
  57. }
  58. if q.listDeviceInfosStmt, err = db.PrepareContext(ctx, listDeviceInfos); err != nil {
  59. return nil, fmt.Errorf("error preparing query ListDeviceInfos: %w", err)
  60. }
  61. if q.replaceDeviceAssignmentStmt, err = db.PrepareContext(ctx, replaceDeviceAssignment); err != nil {
  62. return nil, fmt.Errorf("error preparing query ReplaceDeviceAssignment: %w", err)
  63. }
  64. if q.replaceDeviceAuthStmt, err = db.PrepareContext(ctx, replaceDeviceAuth); err != nil {
  65. return nil, fmt.Errorf("error preparing query ReplaceDeviceAuth: %w", err)
  66. }
  67. if q.replaceDeviceInfoStmt, err = db.PrepareContext(ctx, replaceDeviceInfo); err != nil {
  68. return nil, fmt.Errorf("error preparing query ReplaceDeviceInfo: %w", err)
  69. }
  70. return &q, nil
  71. }
  72. func (q *Queries) Close() error {
  73. var err error
  74. if q.deleteDeviceAliasStmt != nil {
  75. if cerr := q.deleteDeviceAliasStmt.Close(); cerr != nil {
  76. err = fmt.Errorf("error closing deleteDeviceAliasStmt: %w", cerr)
  77. }
  78. }
  79. if q.deleteDeviceAliasByIDStmt != nil {
  80. if cerr := q.deleteDeviceAliasByIDStmt.Close(); cerr != nil {
  81. err = fmt.Errorf("error closing deleteDeviceAliasByIDStmt: %w", cerr)
  82. }
  83. }
  84. if q.deleteDeviceAliasByIDLikeStmt != nil {
  85. if cerr := q.deleteDeviceAliasByIDLikeStmt.Close(); cerr != nil {
  86. err = fmt.Errorf("error closing deleteDeviceAliasByIDLikeStmt: %w", cerr)
  87. }
  88. }
  89. if q.deleteDeviceAssignmentStmt != nil {
  90. if cerr := q.deleteDeviceAssignmentStmt.Close(); cerr != nil {
  91. err = fmt.Errorf("error closing deleteDeviceAssignmentStmt: %w", cerr)
  92. }
  93. }
  94. if q.deleteDeviceAuthStmt != nil {
  95. if cerr := q.deleteDeviceAuthStmt.Close(); cerr != nil {
  96. err = fmt.Errorf("error closing deleteDeviceAuthStmt: %w", cerr)
  97. }
  98. }
  99. if q.deleteDeviceInfoStmt != nil {
  100. if cerr := q.deleteDeviceInfoStmt.Close(); cerr != nil {
  101. err = fmt.Errorf("error closing deleteDeviceInfoStmt: %w", cerr)
  102. }
  103. }
  104. if q.deleteDeviceInfoByIDStmt != nil {
  105. if cerr := q.deleteDeviceInfoByIDStmt.Close(); cerr != nil {
  106. err = fmt.Errorf("error closing deleteDeviceInfoByIDStmt: %w", cerr)
  107. }
  108. }
  109. if q.deleteDeviceInfoLikeStmt != nil {
  110. if cerr := q.deleteDeviceInfoLikeStmt.Close(); cerr != nil {
  111. err = fmt.Errorf("error closing deleteDeviceInfoLikeStmt: %w", cerr)
  112. }
  113. }
  114. if q.insertDeviceAliasStmt != nil {
  115. if cerr := q.insertDeviceAliasStmt.Close(); cerr != nil {
  116. err = fmt.Errorf("error closing insertDeviceAliasStmt: %w", cerr)
  117. }
  118. }
  119. if q.listDeviceAliasesStmt != nil {
  120. if cerr := q.listDeviceAliasesStmt.Close(); cerr != nil {
  121. err = fmt.Errorf("error closing listDeviceAliasesStmt: %w", cerr)
  122. }
  123. }
  124. if q.listDeviceAssignmentsStmt != nil {
  125. if cerr := q.listDeviceAssignmentsStmt.Close(); cerr != nil {
  126. err = fmt.Errorf("error closing listDeviceAssignmentsStmt: %w", cerr)
  127. }
  128. }
  129. if q.listDeviceAuthStmt != nil {
  130. if cerr := q.listDeviceAuthStmt.Close(); cerr != nil {
  131. err = fmt.Errorf("error closing listDeviceAuthStmt: %w", cerr)
  132. }
  133. }
  134. if q.listDeviceInfosStmt != nil {
  135. if cerr := q.listDeviceInfosStmt.Close(); cerr != nil {
  136. err = fmt.Errorf("error closing listDeviceInfosStmt: %w", cerr)
  137. }
  138. }
  139. if q.replaceDeviceAssignmentStmt != nil {
  140. if cerr := q.replaceDeviceAssignmentStmt.Close(); cerr != nil {
  141. err = fmt.Errorf("error closing replaceDeviceAssignmentStmt: %w", cerr)
  142. }
  143. }
  144. if q.replaceDeviceAuthStmt != nil {
  145. if cerr := q.replaceDeviceAuthStmt.Close(); cerr != nil {
  146. err = fmt.Errorf("error closing replaceDeviceAuthStmt: %w", cerr)
  147. }
  148. }
  149. if q.replaceDeviceInfoStmt != nil {
  150. if cerr := q.replaceDeviceInfoStmt.Close(); cerr != nil {
  151. err = fmt.Errorf("error closing replaceDeviceInfoStmt: %w", cerr)
  152. }
  153. }
  154. return err
  155. }
  156. func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) {
  157. switch {
  158. case stmt != nil && q.tx != nil:
  159. return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...)
  160. case stmt != nil:
  161. return stmt.ExecContext(ctx, args...)
  162. default:
  163. return q.db.ExecContext(ctx, query, args...)
  164. }
  165. }
  166. func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) {
  167. switch {
  168. case stmt != nil && q.tx != nil:
  169. return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...)
  170. case stmt != nil:
  171. return stmt.QueryContext(ctx, args...)
  172. default:
  173. return q.db.QueryContext(ctx, query, args...)
  174. }
  175. }
  176. func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row {
  177. switch {
  178. case stmt != nil && q.tx != nil:
  179. return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)
  180. case stmt != nil:
  181. return stmt.QueryRowContext(ctx, args...)
  182. default:
  183. return q.db.QueryRowContext(ctx, query, args...)
  184. }
  185. }
  186. type Queries struct {
  187. db DBTX
  188. tx *sql.Tx
  189. deleteDeviceAliasStmt *sql.Stmt
  190. deleteDeviceAliasByIDStmt *sql.Stmt
  191. deleteDeviceAliasByIDLikeStmt *sql.Stmt
  192. deleteDeviceAssignmentStmt *sql.Stmt
  193. deleteDeviceAuthStmt *sql.Stmt
  194. deleteDeviceInfoStmt *sql.Stmt
  195. deleteDeviceInfoByIDStmt *sql.Stmt
  196. deleteDeviceInfoLikeStmt *sql.Stmt
  197. insertDeviceAliasStmt *sql.Stmt
  198. listDeviceAliasesStmt *sql.Stmt
  199. listDeviceAssignmentsStmt *sql.Stmt
  200. listDeviceAuthStmt *sql.Stmt
  201. listDeviceInfosStmt *sql.Stmt
  202. replaceDeviceAssignmentStmt *sql.Stmt
  203. replaceDeviceAuthStmt *sql.Stmt
  204. replaceDeviceInfoStmt *sql.Stmt
  205. }
  206. func (q *Queries) WithTx(tx *sql.Tx) *Queries {
  207. return &Queries{
  208. db: tx,
  209. tx: tx,
  210. deleteDeviceAliasStmt: q.deleteDeviceAliasStmt,
  211. deleteDeviceAliasByIDStmt: q.deleteDeviceAliasByIDStmt,
  212. deleteDeviceAliasByIDLikeStmt: q.deleteDeviceAliasByIDLikeStmt,
  213. deleteDeviceAssignmentStmt: q.deleteDeviceAssignmentStmt,
  214. deleteDeviceAuthStmt: q.deleteDeviceAuthStmt,
  215. deleteDeviceInfoStmt: q.deleteDeviceInfoStmt,
  216. deleteDeviceInfoByIDStmt: q.deleteDeviceInfoByIDStmt,
  217. deleteDeviceInfoLikeStmt: q.deleteDeviceInfoLikeStmt,
  218. insertDeviceAliasStmt: q.insertDeviceAliasStmt,
  219. listDeviceAliasesStmt: q.listDeviceAliasesStmt,
  220. listDeviceAssignmentsStmt: q.listDeviceAssignmentsStmt,
  221. listDeviceAuthStmt: q.listDeviceAuthStmt,
  222. listDeviceInfosStmt: q.listDeviceInfosStmt,
  223. replaceDeviceAssignmentStmt: q.replaceDeviceAssignmentStmt,
  224. replaceDeviceAuthStmt: q.replaceDeviceAuthStmt,
  225. replaceDeviceInfoStmt: q.replaceDeviceInfoStmt,
  226. }
  227. }