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.

308 lines
12 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
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.deleteScriptTriggerStmt, err = db.PrepareContext(ctx, deleteScriptTrigger); err != nil {
  47. return nil, fmt.Errorf("error preparing query DeleteScriptTrigger: %w", err)
  48. }
  49. if q.insertDeviceAliasStmt, err = db.PrepareContext(ctx, insertDeviceAlias); err != nil {
  50. return nil, fmt.Errorf("error preparing query InsertDeviceAlias: %w", err)
  51. }
  52. if q.listDeviceAliasesStmt, err = db.PrepareContext(ctx, listDeviceAliases); err != nil {
  53. return nil, fmt.Errorf("error preparing query ListDeviceAliases: %w", err)
  54. }
  55. if q.listDeviceAssignmentsStmt, err = db.PrepareContext(ctx, listDeviceAssignments); err != nil {
  56. return nil, fmt.Errorf("error preparing query ListDeviceAssignments: %w", err)
  57. }
  58. if q.listDeviceAuthStmt, err = db.PrepareContext(ctx, listDeviceAuth); err != nil {
  59. return nil, fmt.Errorf("error preparing query ListDeviceAuth: %w", err)
  60. }
  61. if q.listDeviceInfosStmt, err = db.PrepareContext(ctx, listDeviceInfos); err != nil {
  62. return nil, fmt.Errorf("error preparing query ListDeviceInfos: %w", err)
  63. }
  64. if q.listScriptTriggersStmt, err = db.PrepareContext(ctx, listScriptTriggers); err != nil {
  65. return nil, fmt.Errorf("error preparing query ListScriptTriggers: %w", err)
  66. }
  67. if q.listScriptVariablesStmt, err = db.PrepareContext(ctx, listScriptVariables); err != nil {
  68. return nil, fmt.Errorf("error preparing query ListScriptVariables: %w", err)
  69. }
  70. if q.listScriptsStmt, err = db.PrepareContext(ctx, listScripts); err != nil {
  71. return nil, fmt.Errorf("error preparing query ListScripts: %w", err)
  72. }
  73. if q.replaceDeviceAssignmentStmt, err = db.PrepareContext(ctx, replaceDeviceAssignment); err != nil {
  74. return nil, fmt.Errorf("error preparing query ReplaceDeviceAssignment: %w", err)
  75. }
  76. if q.replaceDeviceAuthStmt, err = db.PrepareContext(ctx, replaceDeviceAuth); err != nil {
  77. return nil, fmt.Errorf("error preparing query ReplaceDeviceAuth: %w", err)
  78. }
  79. if q.replaceDeviceInfoStmt, err = db.PrepareContext(ctx, replaceDeviceInfo); err != nil {
  80. return nil, fmt.Errorf("error preparing query ReplaceDeviceInfo: %w", err)
  81. }
  82. if q.replaceScriptTriggerStmt, err = db.PrepareContext(ctx, replaceScriptTrigger); err != nil {
  83. return nil, fmt.Errorf("error preparing query ReplaceScriptTrigger: %w", err)
  84. }
  85. if q.saveScriptStmt, err = db.PrepareContext(ctx, saveScript); err != nil {
  86. return nil, fmt.Errorf("error preparing query SaveScript: %w", err)
  87. }
  88. if q.updateScriptVariablesStmt, err = db.PrepareContext(ctx, updateScriptVariables); err != nil {
  89. return nil, fmt.Errorf("error preparing query UpdateScriptVariables: %w", err)
  90. }
  91. return &q, nil
  92. }
  93. func (q *Queries) Close() error {
  94. var err error
  95. if q.deleteDeviceAliasStmt != nil {
  96. if cerr := q.deleteDeviceAliasStmt.Close(); cerr != nil {
  97. err = fmt.Errorf("error closing deleteDeviceAliasStmt: %w", cerr)
  98. }
  99. }
  100. if q.deleteDeviceAliasByIDStmt != nil {
  101. if cerr := q.deleteDeviceAliasByIDStmt.Close(); cerr != nil {
  102. err = fmt.Errorf("error closing deleteDeviceAliasByIDStmt: %w", cerr)
  103. }
  104. }
  105. if q.deleteDeviceAliasByIDLikeStmt != nil {
  106. if cerr := q.deleteDeviceAliasByIDLikeStmt.Close(); cerr != nil {
  107. err = fmt.Errorf("error closing deleteDeviceAliasByIDLikeStmt: %w", cerr)
  108. }
  109. }
  110. if q.deleteDeviceAssignmentStmt != nil {
  111. if cerr := q.deleteDeviceAssignmentStmt.Close(); cerr != nil {
  112. err = fmt.Errorf("error closing deleteDeviceAssignmentStmt: %w", cerr)
  113. }
  114. }
  115. if q.deleteDeviceAuthStmt != nil {
  116. if cerr := q.deleteDeviceAuthStmt.Close(); cerr != nil {
  117. err = fmt.Errorf("error closing deleteDeviceAuthStmt: %w", cerr)
  118. }
  119. }
  120. if q.deleteDeviceInfoStmt != nil {
  121. if cerr := q.deleteDeviceInfoStmt.Close(); cerr != nil {
  122. err = fmt.Errorf("error closing deleteDeviceInfoStmt: %w", cerr)
  123. }
  124. }
  125. if q.deleteDeviceInfoByIDStmt != nil {
  126. if cerr := q.deleteDeviceInfoByIDStmt.Close(); cerr != nil {
  127. err = fmt.Errorf("error closing deleteDeviceInfoByIDStmt: %w", cerr)
  128. }
  129. }
  130. if q.deleteDeviceInfoLikeStmt != nil {
  131. if cerr := q.deleteDeviceInfoLikeStmt.Close(); cerr != nil {
  132. err = fmt.Errorf("error closing deleteDeviceInfoLikeStmt: %w", cerr)
  133. }
  134. }
  135. if q.deleteScriptTriggerStmt != nil {
  136. if cerr := q.deleteScriptTriggerStmt.Close(); cerr != nil {
  137. err = fmt.Errorf("error closing deleteScriptTriggerStmt: %w", cerr)
  138. }
  139. }
  140. if q.insertDeviceAliasStmt != nil {
  141. if cerr := q.insertDeviceAliasStmt.Close(); cerr != nil {
  142. err = fmt.Errorf("error closing insertDeviceAliasStmt: %w", cerr)
  143. }
  144. }
  145. if q.listDeviceAliasesStmt != nil {
  146. if cerr := q.listDeviceAliasesStmt.Close(); cerr != nil {
  147. err = fmt.Errorf("error closing listDeviceAliasesStmt: %w", cerr)
  148. }
  149. }
  150. if q.listDeviceAssignmentsStmt != nil {
  151. if cerr := q.listDeviceAssignmentsStmt.Close(); cerr != nil {
  152. err = fmt.Errorf("error closing listDeviceAssignmentsStmt: %w", cerr)
  153. }
  154. }
  155. if q.listDeviceAuthStmt != nil {
  156. if cerr := q.listDeviceAuthStmt.Close(); cerr != nil {
  157. err = fmt.Errorf("error closing listDeviceAuthStmt: %w", cerr)
  158. }
  159. }
  160. if q.listDeviceInfosStmt != nil {
  161. if cerr := q.listDeviceInfosStmt.Close(); cerr != nil {
  162. err = fmt.Errorf("error closing listDeviceInfosStmt: %w", cerr)
  163. }
  164. }
  165. if q.listScriptTriggersStmt != nil {
  166. if cerr := q.listScriptTriggersStmt.Close(); cerr != nil {
  167. err = fmt.Errorf("error closing listScriptTriggersStmt: %w", cerr)
  168. }
  169. }
  170. if q.listScriptVariablesStmt != nil {
  171. if cerr := q.listScriptVariablesStmt.Close(); cerr != nil {
  172. err = fmt.Errorf("error closing listScriptVariablesStmt: %w", cerr)
  173. }
  174. }
  175. if q.listScriptsStmt != nil {
  176. if cerr := q.listScriptsStmt.Close(); cerr != nil {
  177. err = fmt.Errorf("error closing listScriptsStmt: %w", cerr)
  178. }
  179. }
  180. if q.replaceDeviceAssignmentStmt != nil {
  181. if cerr := q.replaceDeviceAssignmentStmt.Close(); cerr != nil {
  182. err = fmt.Errorf("error closing replaceDeviceAssignmentStmt: %w", cerr)
  183. }
  184. }
  185. if q.replaceDeviceAuthStmt != nil {
  186. if cerr := q.replaceDeviceAuthStmt.Close(); cerr != nil {
  187. err = fmt.Errorf("error closing replaceDeviceAuthStmt: %w", cerr)
  188. }
  189. }
  190. if q.replaceDeviceInfoStmt != nil {
  191. if cerr := q.replaceDeviceInfoStmt.Close(); cerr != nil {
  192. err = fmt.Errorf("error closing replaceDeviceInfoStmt: %w", cerr)
  193. }
  194. }
  195. if q.replaceScriptTriggerStmt != nil {
  196. if cerr := q.replaceScriptTriggerStmt.Close(); cerr != nil {
  197. err = fmt.Errorf("error closing replaceScriptTriggerStmt: %w", cerr)
  198. }
  199. }
  200. if q.saveScriptStmt != nil {
  201. if cerr := q.saveScriptStmt.Close(); cerr != nil {
  202. err = fmt.Errorf("error closing saveScriptStmt: %w", cerr)
  203. }
  204. }
  205. if q.updateScriptVariablesStmt != nil {
  206. if cerr := q.updateScriptVariablesStmt.Close(); cerr != nil {
  207. err = fmt.Errorf("error closing updateScriptVariablesStmt: %w", cerr)
  208. }
  209. }
  210. return err
  211. }
  212. func (q *Queries) exec(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (sql.Result, error) {
  213. switch {
  214. case stmt != nil && q.tx != nil:
  215. return q.tx.StmtContext(ctx, stmt).ExecContext(ctx, args...)
  216. case stmt != nil:
  217. return stmt.ExecContext(ctx, args...)
  218. default:
  219. return q.db.ExecContext(ctx, query, args...)
  220. }
  221. }
  222. func (q *Queries) query(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) (*sql.Rows, error) {
  223. switch {
  224. case stmt != nil && q.tx != nil:
  225. return q.tx.StmtContext(ctx, stmt).QueryContext(ctx, args...)
  226. case stmt != nil:
  227. return stmt.QueryContext(ctx, args...)
  228. default:
  229. return q.db.QueryContext(ctx, query, args...)
  230. }
  231. }
  232. func (q *Queries) queryRow(ctx context.Context, stmt *sql.Stmt, query string, args ...interface{}) *sql.Row {
  233. switch {
  234. case stmt != nil && q.tx != nil:
  235. return q.tx.StmtContext(ctx, stmt).QueryRowContext(ctx, args...)
  236. case stmt != nil:
  237. return stmt.QueryRowContext(ctx, args...)
  238. default:
  239. return q.db.QueryRowContext(ctx, query, args...)
  240. }
  241. }
  242. type Queries struct {
  243. db DBTX
  244. tx *sql.Tx
  245. deleteDeviceAliasStmt *sql.Stmt
  246. deleteDeviceAliasByIDStmt *sql.Stmt
  247. deleteDeviceAliasByIDLikeStmt *sql.Stmt
  248. deleteDeviceAssignmentStmt *sql.Stmt
  249. deleteDeviceAuthStmt *sql.Stmt
  250. deleteDeviceInfoStmt *sql.Stmt
  251. deleteDeviceInfoByIDStmt *sql.Stmt
  252. deleteDeviceInfoLikeStmt *sql.Stmt
  253. deleteScriptTriggerStmt *sql.Stmt
  254. insertDeviceAliasStmt *sql.Stmt
  255. listDeviceAliasesStmt *sql.Stmt
  256. listDeviceAssignmentsStmt *sql.Stmt
  257. listDeviceAuthStmt *sql.Stmt
  258. listDeviceInfosStmt *sql.Stmt
  259. listScriptTriggersStmt *sql.Stmt
  260. listScriptVariablesStmt *sql.Stmt
  261. listScriptsStmt *sql.Stmt
  262. replaceDeviceAssignmentStmt *sql.Stmt
  263. replaceDeviceAuthStmt *sql.Stmt
  264. replaceDeviceInfoStmt *sql.Stmt
  265. replaceScriptTriggerStmt *sql.Stmt
  266. saveScriptStmt *sql.Stmt
  267. updateScriptVariablesStmt *sql.Stmt
  268. }
  269. func (q *Queries) WithTx(tx *sql.Tx) *Queries {
  270. return &Queries{
  271. db: tx,
  272. tx: tx,
  273. deleteDeviceAliasStmt: q.deleteDeviceAliasStmt,
  274. deleteDeviceAliasByIDStmt: q.deleteDeviceAliasByIDStmt,
  275. deleteDeviceAliasByIDLikeStmt: q.deleteDeviceAliasByIDLikeStmt,
  276. deleteDeviceAssignmentStmt: q.deleteDeviceAssignmentStmt,
  277. deleteDeviceAuthStmt: q.deleteDeviceAuthStmt,
  278. deleteDeviceInfoStmt: q.deleteDeviceInfoStmt,
  279. deleteDeviceInfoByIDStmt: q.deleteDeviceInfoByIDStmt,
  280. deleteDeviceInfoLikeStmt: q.deleteDeviceInfoLikeStmt,
  281. deleteScriptTriggerStmt: q.deleteScriptTriggerStmt,
  282. insertDeviceAliasStmt: q.insertDeviceAliasStmt,
  283. listDeviceAliasesStmt: q.listDeviceAliasesStmt,
  284. listDeviceAssignmentsStmt: q.listDeviceAssignmentsStmt,
  285. listDeviceAuthStmt: q.listDeviceAuthStmt,
  286. listDeviceInfosStmt: q.listDeviceInfosStmt,
  287. listScriptTriggersStmt: q.listScriptTriggersStmt,
  288. listScriptVariablesStmt: q.listScriptVariablesStmt,
  289. listScriptsStmt: q.listScriptsStmt,
  290. replaceDeviceAssignmentStmt: q.replaceDeviceAssignmentStmt,
  291. replaceDeviceAuthStmt: q.replaceDeviceAuthStmt,
  292. replaceDeviceInfoStmt: q.replaceDeviceInfoStmt,
  293. replaceScriptTriggerStmt: q.replaceScriptTriggerStmt,
  294. saveScriptStmt: q.saveScriptStmt,
  295. updateScriptVariablesStmt: q.updateScriptVariablesStmt,
  296. }
  297. }