Skip to content

Commit

Permalink
fix(tidb-reserverd-word): groups, rank
Browse files Browse the repository at this point in the history
  • Loading branch information
wd0517 committed Feb 16, 2020
1 parent cc1bb97 commit 1cbc869
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class FixUserUsernamesAndGroupNamesClash < Jobs::Scheduled
every 1.week

def execute(args)
User.joins("LEFT JOIN groups ON lower(groups.name) = users.username_lower")
User.joins("LEFT JOIN `groups` ON lower(groups.name) = users.username_lower")
.where("groups.id IS NOT NULL")
.find_each do |user|

Expand Down
2 changes: 1 addition & 1 deletion app/models/post_revision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def self.ensure_consistency!
DB.exec <<-SQL
UPDATE post_revisions
JOIN (
SELECT id, @row_number:=CASE WHEN @post_id=post_id THEN @row_number+1 ELSE 1 END AS rank,
SELECT id, @row_number:=CASE WHEN @post_id=post_id THEN @row_number+1 ELSE 1 END AS `rank`,
@post_id:=post_id
FROM post_revisions, (SELECT @row_number:=0,@post_id:='') AS t
ORDER BY post_id, number, created_at, updated_at
Expand Down
2 changes: 1 addition & 1 deletion lib/score_calculator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def update_posts_rank(opts)
JOIN (
SELECT id, case when c = 1 then 1 else (`rank` -1)/(c - 1) end as percent_rank
FROM (select posts.id,posts.topic_id,
posts.score, count(lesser.id) + 1 as rank
posts.score, count(lesser.id) + 1 as `rank`
from posts
left join posts as lesser on lesser.score < posts.score and lesser.topic_id = posts.topic_id
group by posts.id
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/import.rake
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def update_groups
FROM group_users
GROUP BY group_id
)
UPDATE groups
UPDATE `groups`
SET user_count = X.count
FROM X
WHERE id = X.group_id
Expand Down

0 comments on commit 1cbc869

Please sign in to comment.