github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/gen_mysql.go (about) 1 // +build !pgsql,!mssql 2 3 /* This file was generated by Gosora's Query Generator. Please try to avoid modifying this file, as it might change at any time. */ 4 5 package main 6 7 import "log" 8 import "database/sql" 9 import "github.com/Azareal/Gosora/common" 10 //import "github.com/Azareal/Gosora/query_gen" 11 12 // nolint 13 type Stmts struct { 14 forumEntryExists *sql.Stmt 15 groupEntryExists *sql.Stmt 16 getForumTopics *sql.Stmt 17 addForumPermsToForum *sql.Stmt 18 updateEmail *sql.Stmt 19 setTempGroup *sql.Stmt 20 bumpSync *sql.Stmt 21 deleteActivityStreamMatch *sql.Stmt 22 23 getActivityFeedByWatcher *sql.Stmt 24 getActivityCountByWatcher *sql.Stmt 25 26 Mocks bool 27 } 28 29 // nolint 30 func _gen_mysql() (err error) { 31 common.DebugLog("Building the generated statements") 32 33 common.DebugLog("Preparing forumEntryExists statement.") 34 stmts.forumEntryExists, err = db.Prepare("SELECT `fid` FROM `forums` WHERE `name` = '' ORDER BY `fid` ASC LIMIT 0,1") 35 if err != nil { 36 log.Print("Error in forumEntryExists statement.") 37 return err 38 } 39 40 common.DebugLog("Preparing groupEntryExists statement.") 41 stmts.groupEntryExists, err = db.Prepare("SELECT `gid` FROM `users_groups` WHERE `name` = '' ORDER BY `gid` ASC LIMIT 0,1") 42 if err != nil { 43 log.Print("Error in groupEntryExists statement.") 44 return err 45 } 46 47 common.DebugLog("Preparing getForumTopics statement.") 48 stmts.getForumTopics, err = db.Prepare("SELECT `topics`.`tid`, `topics`.`title`, `topics`.`content`, `topics`.`createdBy`, `topics`.`is_closed`, `topics`.`sticky`, `topics`.`createdAt`, `topics`.`lastReplyAt`, `topics`.`parentID`, `users`.`name`, `users`.`avatar` FROM `topics` LEFT JOIN `users` ON `topics`.`createdBy` = `users`.`uid` WHERE `topics`.`parentID` = ? ORDER BY `topics`.`sticky` DESC,`topics`.`lastReplyAt` DESC,`topics`.`createdBy` DESC") 49 if err != nil { 50 log.Print("Error in getForumTopics statement.") 51 return err 52 } 53 54 common.DebugLog("Preparing addForumPermsToForum statement.") 55 stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO `forums_permissions`(`gid`,`fid`,`preset`,`permissions`) VALUES (?,?,?,?)") 56 if err != nil { 57 log.Print("Error in addForumPermsToForum statement.") 58 return err 59 } 60 61 common.DebugLog("Preparing updateEmail statement.") 62 stmts.updateEmail, err = db.Prepare("UPDATE `emails` SET `email`= ?,`uid`= ?,`validated`= ?,`token`= ? WHERE `email` = ?") 63 if err != nil { 64 log.Print("Error in updateEmail statement.") 65 return err 66 } 67 68 common.DebugLog("Preparing setTempGroup statement.") 69 stmts.setTempGroup, err = db.Prepare("UPDATE `users` SET `temp_group`= ? WHERE `uid` = ?") 70 if err != nil { 71 log.Print("Error in setTempGroup statement.") 72 return err 73 } 74 75 common.DebugLog("Preparing bumpSync statement.") 76 stmts.bumpSync, err = db.Prepare("UPDATE `sync` SET `last_update`= UTC_TIMESTAMP()") 77 if err != nil { 78 log.Print("Error in bumpSync statement.") 79 return err 80 } 81 82 common.DebugLog("Preparing deleteActivityStreamMatch statement.") 83 stmts.deleteActivityStreamMatch, err = db.Prepare("DELETE FROM `activity_stream_matches` WHERE `watcher` = ? AND `asid` = ?") 84 if err != nil { 85 log.Print("Error in deleteActivityStreamMatch statement.") 86 return err 87 } 88 89 return nil 90 }