@@ -1886,8 +1886,13 @@ func GetWatchers(repoID int64) ([]*Watch, error) {
1886
1886
// Repository.GetWatchers returns range of users watching given repository.
1887
1887
func (repo * Repository ) GetWatchers (page int ) ([]* User , error ) {
1888
1888
users := make ([]* User , 0 , ItemsPerPage )
1889
- return users , x .Limit (ItemsPerPage , (page - 1 )* ItemsPerPage ).
1890
- Where ("repo_id=?" , repo .ID ).Join ("LEFT" , "watch" , "user.id=watch.user_id" ).Find (& users )
1889
+ sess := x .Limit (ItemsPerPage , (page - 1 )* ItemsPerPage ).Where ("watch.repo_id=?" , repo .ID )
1890
+ if setting .UsePostgreSQL {
1891
+ sess = sess .Join ("LEFT" , "watch" , `"user".id=watch.user_id` )
1892
+ } else {
1893
+ sess = sess .Join ("LEFT" , "watch" , "user.id=watch.user_id" )
1894
+ }
1895
+ return users , sess .Find (& users )
1891
1896
}
1892
1897
1893
1898
func notifyWatchers (e Engine , act * Action ) error {
@@ -1969,8 +1974,13 @@ func IsStaring(uid, repoId int64) bool {
1969
1974
1970
1975
func (repo * Repository ) GetStargazers (page int ) ([]* User , error ) {
1971
1976
users := make ([]* User , 0 , ItemsPerPage )
1972
- return users , x .Limit (ItemsPerPage , (page - 1 )* ItemsPerPage ).
1973
- Where ("repo_id=?" , repo .ID ).Join ("LEFT" , "star" , "user.id=star.uid" ).Find (& users )
1977
+ sess := x .Limit (ItemsPerPage , (page - 1 )* ItemsPerPage ).Where ("star.repo_id=?" , repo .ID )
1978
+ if setting .UsePostgreSQL {
1979
+ sess = sess .Join ("LEFT" , "star" , `"user".id=star.uid` )
1980
+ } else {
1981
+ sess = sess .Join ("LEFT" , "star" , "user.id=star.uid" )
1982
+ }
1983
+ return users , sess .Find (& users )
1974
1984
}
1975
1985
1976
1986
// ___________ __
0 commit comments