2017-07-12 11:05:18 +00:00
|
|
|
// +build pgsql
|
|
|
|
|
|
|
|
// This file was generated by Gosora's Query Generator. Please try to avoid modifying this file, as it might change at any time.
|
|
|
|
package main
|
|
|
|
|
|
|
|
import "log"
|
|
|
|
import "database/sql"
|
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
// nolint
|
2017-11-05 09:55:34 +00:00
|
|
|
type Stmts struct {
|
|
|
|
addRepliesToTopic *sql.Stmt
|
|
|
|
removeRepliesFromTopic *sql.Stmt
|
|
|
|
addTopicsToForum *sql.Stmt
|
|
|
|
removeTopicsFromForum *sql.Stmt
|
|
|
|
updateForumCache *sql.Stmt
|
|
|
|
addLikesToTopic *sql.Stmt
|
|
|
|
addLikesToReply *sql.Stmt
|
|
|
|
editTopic *sql.Stmt
|
|
|
|
editReply *sql.Stmt
|
|
|
|
stickTopic *sql.Stmt
|
|
|
|
unstickTopic *sql.Stmt
|
|
|
|
lockTopic *sql.Stmt
|
|
|
|
unlockTopic *sql.Stmt
|
|
|
|
updateLastIP *sql.Stmt
|
|
|
|
updateSession *sql.Stmt
|
|
|
|
setPassword *sql.Stmt
|
|
|
|
setAvatar *sql.Stmt
|
|
|
|
setUsername *sql.Stmt
|
|
|
|
changeGroup *sql.Stmt
|
|
|
|
activateUser *sql.Stmt
|
|
|
|
updateUserLevel *sql.Stmt
|
|
|
|
incrementUserScore *sql.Stmt
|
|
|
|
incrementUserPosts *sql.Stmt
|
|
|
|
incrementUserBigposts *sql.Stmt
|
|
|
|
incrementUserMegaposts *sql.Stmt
|
|
|
|
incrementUserTopics *sql.Stmt
|
|
|
|
editProfileReply *sql.Stmt
|
|
|
|
updateForum *sql.Stmt
|
|
|
|
updateSetting *sql.Stmt
|
|
|
|
updatePlugin *sql.Stmt
|
|
|
|
updatePluginInstall *sql.Stmt
|
|
|
|
updateTheme *sql.Stmt
|
|
|
|
updateUser *sql.Stmt
|
|
|
|
updateUserGroup *sql.Stmt
|
|
|
|
updateGroupPerms *sql.Stmt
|
|
|
|
updateGroupRank *sql.Stmt
|
|
|
|
updateGroup *sql.Stmt
|
|
|
|
updateEmail *sql.Stmt
|
|
|
|
verifyEmail *sql.Stmt
|
|
|
|
setTempGroup *sql.Stmt
|
|
|
|
updateWordFilter *sql.Stmt
|
|
|
|
bumpSync *sql.Stmt
|
|
|
|
|
|
|
|
getActivityFeedByWatcher *sql.Stmt
|
|
|
|
getActivityCountByWatcher *sql.Stmt
|
|
|
|
todaysPostCount *sql.Stmt
|
|
|
|
todaysTopicCount *sql.Stmt
|
|
|
|
todaysReportCount *sql.Stmt
|
|
|
|
todaysNewUserCount *sql.Stmt
|
|
|
|
findUsersByIPUsers *sql.Stmt
|
|
|
|
findUsersByIPTopics *sql.Stmt
|
|
|
|
findUsersByIPReplies *sql.Stmt
|
|
|
|
|
|
|
|
Mocks bool
|
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
|
2017-09-03 04:50:31 +00:00
|
|
|
// nolint
|
2017-07-12 11:05:18 +00:00
|
|
|
func _gen_pgsql() (err error) {
|
2017-07-17 10:23:42 +00:00
|
|
|
if dev.DebugMode {
|
2017-07-12 11:05:18 +00:00
|
|
|
log.Print("Building the generated statements")
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing addRepliesToTopic statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.addRepliesToTopic, err = db.Prepare("UPDATE `topics` SET `postCount` = `postCount` + ?,`lastReplyBy` = ?,`lastReplyAt` = LOCALTIMESTAMP() WHERE `tid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing removeRepliesFromTopic statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.removeRepliesFromTopic, err = db.Prepare("UPDATE `topics` SET `postCount` = `postCount` - ? WHERE `tid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing addTopicsToForum statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.addTopicsToForum, err = db.Prepare("UPDATE `forums` SET `topicCount` = `topicCount` + ? WHERE `fid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing removeTopicsFromForum statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.removeTopicsFromForum, err = db.Prepare("UPDATE `forums` SET `topicCount` = `topicCount` - ? WHERE `fid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateForumCache statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateForumCache, err = db.Prepare("UPDATE `forums` SET `lastTopicID` = ?,`lastReplyerID` = ? WHERE `fid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing addLikesToTopic statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.addLikesToTopic, err = db.Prepare("UPDATE `topics` SET `likeCount` = `likeCount` + ? WHERE `tid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing addLikesToReply statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.addLikesToReply, err = db.Prepare("UPDATE `replies` SET `likeCount` = `likeCount` + ? WHERE `rid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing editTopic statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.editTopic, err = db.Prepare("UPDATE `topics` SET `title` = ?,`content` = ?,`parsed_content` = ? WHERE `tid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing editReply statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.editReply, err = db.Prepare("UPDATE `replies` SET `content` = ?,`parsed_content` = ? WHERE `rid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing stickTopic statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.stickTopic, err = db.Prepare("UPDATE `topics` SET `sticky` = 1 WHERE `tid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing unstickTopic statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.unstickTopic, err = db.Prepare("UPDATE `topics` SET `sticky` = 0 WHERE `tid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-22 02:21:17 +00:00
|
|
|
log.Print("Preparing lockTopic statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.lockTopic, err = db.Prepare("UPDATE `topics` SET `is_closed` = 1 WHERE `tid` = ?")
|
2017-09-22 02:21:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Print("Preparing unlockTopic statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.unlockTopic, err = db.Prepare("UPDATE `topics` SET `is_closed` = 0 WHERE `tid` = ?")
|
2017-09-22 02:21:17 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateLastIP statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateLastIP, err = db.Prepare("UPDATE `users` SET `last_ip` = ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateSession statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateSession, err = db.Prepare("UPDATE `users` SET `session` = ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing setPassword statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.setPassword, err = db.Prepare("UPDATE `users` SET `password` = ?,`salt` = ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing setAvatar statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.setAvatar, err = db.Prepare("UPDATE `users` SET `avatar` = ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing setUsername statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.setUsername, err = db.Prepare("UPDATE `users` SET `name` = ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing changeGroup statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.changeGroup, err = db.Prepare("UPDATE `users` SET `group` = ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing activateUser statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.activateUser, err = db.Prepare("UPDATE `users` SET `active` = 1 WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateUserLevel statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateUserLevel, err = db.Prepare("UPDATE `users` SET `level` = ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing incrementUserScore statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.incrementUserScore, err = db.Prepare("UPDATE `users` SET `score` = `score` + ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing incrementUserPosts statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.incrementUserPosts, err = db.Prepare("UPDATE `users` SET `posts` = `posts` + ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing incrementUserBigposts statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.incrementUserBigposts, err = db.Prepare("UPDATE `users` SET `posts` = `posts` + ?,`bigposts` = `bigposts` + ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing incrementUserMegaposts statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.incrementUserMegaposts, err = db.Prepare("UPDATE `users` SET `posts` = `posts` + ?,`bigposts` = `bigposts` + ?,`megaposts` = `megaposts` + ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing incrementUserTopics statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.incrementUserTopics, err = db.Prepare("UPDATE `users` SET `topics` = `topics` + ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing editProfileReply statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.editProfileReply, err = db.Prepare("UPDATE `users_replies` SET `content` = ?,`parsed_content` = ? WHERE `rid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateForum statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateForum, err = db.Prepare("UPDATE `forums` SET `name` = ?,`desc` = ?,`active` = ?,`preset` = ? WHERE `fid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateSetting statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateSetting, err = db.Prepare("UPDATE `settings` SET `content` = ? WHERE `name` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updatePlugin statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updatePlugin, err = db.Prepare("UPDATE `plugins` SET `active` = ? WHERE `uname` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updatePluginInstall statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updatePluginInstall, err = db.Prepare("UPDATE `plugins` SET `installed` = ? WHERE `uname` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateTheme statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateTheme, err = db.Prepare("UPDATE `themes` SET `default` = ? WHERE `uname` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateUser statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateUser, err = db.Prepare("UPDATE `users` SET `name` = ?,`email` = ?,`group` = ? WHERE `uid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-10-21 00:27:47 +00:00
|
|
|
log.Print("Preparing updateUserGroup statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateUserGroup, err = db.Prepare("UPDATE `users` SET `group` = ? WHERE `uid` = ?")
|
2017-10-21 00:27:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateGroupPerms statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateGroupPerms, err = db.Prepare("UPDATE `users_groups` SET `permissions` = ? WHERE `gid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateGroupRank statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateGroupRank, err = db.Prepare("UPDATE `users_groups` SET `is_admin` = ?,`is_mod` = ?,`is_banned` = ? WHERE `gid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateGroup statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateGroup, err = db.Prepare("UPDATE `users_groups` SET `name` = ?,`tag` = ? WHERE `gid` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateEmail statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateEmail, err = db.Prepare("UPDATE `emails` SET `email` = ?,`uid` = ?,`validated` = ?,`token` = ? WHERE `email` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing verifyEmail statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.verifyEmail, err = db.Prepare("UPDATE `emails` SET `validated` = 1,`token` = '' WHERE `email` = ?")
|
2017-07-12 11:05:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-08-27 09:33:45 +00:00
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing setTempGroup statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.setTempGroup, err = db.Prepare("UPDATE `users` SET `temp_group` = ? WHERE `uid` = ?")
|
2017-08-27 09:33:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing updateWordFilter statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.updateWordFilter, err = db.Prepare("UPDATE `word_filters` SET `find` = ?,`replacement` = ? WHERE `wfid` = ?")
|
2017-08-27 09:33:45 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-09-10 16:57:22 +00:00
|
|
|
|
2017-09-18 17:03:52 +00:00
|
|
|
log.Print("Preparing bumpSync statement.")
|
2017-11-05 09:55:34 +00:00
|
|
|
stmts.bumpSync, err = db.Prepare("UPDATE `sync` SET `last_update` = LOCALTIMESTAMP()")
|
2017-09-10 16:57:22 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-07-12 11:05:18 +00:00
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|