Commit 32747ffc authored by Jonne Haß's avatar Jonne Haß
Browse files

Merge pull request #5026 from jaywink/hotfix-mysql-madness-develop

Use different user.construct_public_followings_sql query depending on database backend
parents c475a398 80075c13
......@@ -69,7 +69,16 @@ module User::Querying
def construct_public_followings_sql(opts)
Rails.logger.debug("[EVIL-QUERY] user.construct_public_followings_sql")
query = opts[:klass].where(:author_id => Person.in_aspects(opts[:by_members_of]).select("people.id"), :public => true, :pending => false)
# For PostgreSQL and MySQL/MariaDB we use a different query
# see issue: https://github.com/diaspora/diaspora/issues/5014
if AppConfig.postgres?
query = opts[:klass].where(:author_id => Person.in_aspects(opts[:by_members_of]).select("people.id"), :public => true, :pending => false)
else
aspects = Aspect.where(:id => opts[:by_members_of])
person_ids = Person.connection.select_values(people_in_aspects(aspects).select("people.id").to_sql)
query = opts[:klass].where(:author_id => person_ids, :public => true, :pending => false)
end
unless(opts[:klass] == Photo)
query = query.where(:type => opts[:type])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment