github.com/Azareal/Gosora@v0.0.0-20210729070923-553e66b59003/gen_mssql.go (about) 1 // +build 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 package main 5 6 import "log" 7 import "database/sql" 8 import "github.com/Azareal/Gosora/common" 9 10 // nolint 11 type Stmts struct { 12 forumEntryExists *sql.Stmt 13 groupEntryExists *sql.Stmt 14 getForumTopics *sql.Stmt 15 addForumPermsToForum *sql.Stmt 16 updateEmail *sql.Stmt 17 setTempGroup *sql.Stmt 18 bumpSync *sql.Stmt 19 deleteActivityStreamMatch *sql.Stmt 20 21 getActivityFeedByWatcher *sql.Stmt 22 getActivityCountByWatcher *sql.Stmt 23 24 Mocks bool 25 } 26 27 // nolint 28 func _gen_mssql() (err error) { 29 common.DebugLog("Building the generated statements") 30 31 common.DebugLog("Preparing forumEntryExists statement.") 32 stmts.forumEntryExists, err = db.Prepare("SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") 33 if err != nil { 34 log.Print("Error in forumEntryExists statement.") 35 log.Print("Bad Query: ","SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") 36 return err 37 } 38 39 common.DebugLog("Preparing groupEntryExists statement.") 40 stmts.groupEntryExists, err = db.Prepare("SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") 41 if err != nil { 42 log.Print("Error in groupEntryExists statement.") 43 log.Print("Bad Query: ","SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") 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] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC") 49 if err != nil { 50 log.Print("Error in getForumTopics statement.") 51 log.Print("Bad Query: ","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] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC") 52 return err 53 } 54 55 common.DebugLog("Preparing addForumPermsToForum statement.") 56 stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)") 57 if err != nil { 58 log.Print("Error in addForumPermsToForum statement.") 59 log.Print("Bad Query: ","INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)") 60 return err 61 } 62 63 common.DebugLog("Preparing updateEmail statement.") 64 stmts.updateEmail, err = db.Prepare("UPDATE [emails] SET [email]= ?,[uid]= ?,[validated]= ?,[token]= ? WHERE [email] = ?") 65 if err != nil { 66 log.Print("Error in updateEmail statement.") 67 log.Print("Bad Query: ","UPDATE [emails] SET [email]= ?,[uid]= ?,[validated]= ?,[token]= ? WHERE [email] = ?") 68 return err 69 } 70 71 common.DebugLog("Preparing setTempGroup statement.") 72 stmts.setTempGroup, err = db.Prepare("UPDATE [users] SET [temp_group]= ? WHERE [uid] = ?") 73 if err != nil { 74 log.Print("Error in setTempGroup statement.") 75 log.Print("Bad Query: ","UPDATE [users] SET [temp_group]= ? WHERE [uid] = ?") 76 return err 77 } 78 79 common.DebugLog("Preparing bumpSync statement.") 80 stmts.bumpSync, err = db.Prepare("UPDATE [sync] SET [last_update]= GETUTCDATE()") 81 if err != nil { 82 log.Print("Error in bumpSync statement.") 83 log.Print("Bad Query: ","UPDATE [sync] SET [last_update]= GETUTCDATE()") 84 return err 85 } 86 87 common.DebugLog("Preparing deleteActivityStreamMatch statement.") 88 stmts.deleteActivityStreamMatch, err = db.Prepare("DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?") 89 if err != nil { 90 log.Print("Error in deleteActivityStreamMatch statement.") 91 log.Print("Bad Query: ","DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?") 92 return err 93 } 94 95 return nil 96 }