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.

318 lines
12 KiB

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