add sqlite method; fix chubbies cukes
This commit is contained in:
parent
607013bc83
commit
5348c72209
4 changed files with 12 additions and 4 deletions
1
Gemfile
1
Gemfile
|
|
@ -126,6 +126,7 @@ group :test do
|
|||
gem 'rspec-rails', '>= 2.0.0'
|
||||
gem "selenium-webdriver", "~> 2.7.0"
|
||||
gem 'webmock', :require => false
|
||||
gem 'sqlite3'
|
||||
end
|
||||
|
||||
group :development do
|
||||
|
|
|
|||
|
|
@ -425,6 +425,7 @@ GEM
|
|||
sinatra (1.2.6)
|
||||
rack (~> 1.1)
|
||||
tilt (< 2.0, >= 1.2.2)
|
||||
sqlite3 (1.3.4)
|
||||
subexec (0.0.4)
|
||||
systemu (2.4.0)
|
||||
term-ansicolor (1.0.6)
|
||||
|
|
@ -534,6 +535,7 @@ DEPENDENCIES
|
|||
selenium-webdriver (~> 2.7.0)
|
||||
settingslogic (= 2.0.6)
|
||||
sod!
|
||||
sqlite3
|
||||
thin (= 1.2.11)
|
||||
twitter (= 1.5.0)
|
||||
typhoeus
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ def postgres?
|
|||
@using_postgres ||= defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter)
|
||||
end
|
||||
|
||||
def sqlite?
|
||||
@using_sqlite ||= defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) && ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter
|
||||
end
|
||||
|
||||
# Load the rails application
|
||||
require File.expand_path('../application', __FILE__)
|
||||
Haml::Template.options[:format] = :html5
|
||||
|
|
|
|||
|
|
@ -39,10 +39,11 @@ module Diaspora
|
|||
posts_from_self = posts_from_self.joins(:aspect_visibilities).where(:aspect_visibilities => {:aspect_id => opts[:by_members_of]})
|
||||
end
|
||||
|
||||
unless defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) && ActiveRecord::Base.connection.class == ActiveRecord::ConnectionAdapters::SQLite3Adapter
|
||||
posts_from_others = posts_from_others.select(select_clause).limit(opts[:limit]).order(order_with_table).where(Post.arel_table[order_field].lt(opts[:max_time]))
|
||||
posts_from_self = posts_from_self.select(select_clause).limit(opts[:limit]).order(order_with_table).where(Post.arel_table[order_field].lt(opts[:max_time]))
|
||||
all_posts = "(#{posts_from_others.to_sql}) UNION ALL (#{posts_from_self.to_sql}) ORDER BY #{opts[:order]} LIMIT #{opts[:limit]}"
|
||||
unless sqlite?
|
||||
posts_from_others = posts_from_others.select(select_clause).order(order_with_table).where(Post.arel_table[order_field].lt(opts[:max_time]))
|
||||
posts_from_self = posts_from_self.select(select_clause).order(order_with_table).where(Post.arel_table[order_field].lt(opts[:max_time]))
|
||||
|
||||
all_posts = "(#{posts_from_others.to_sql} LIMIT #{opts[:limit]}) UNION ALL (#{posts_from_self.to_sql} LIMIT #{opts[:limit]}) ORDER BY #{opts[:order]} LIMIT #{opts[:limit]}"
|
||||
else
|
||||
posts_from_others = posts_from_others.select(select_clause)
|
||||
posts_from_self = posts_from_self.select(select_clause)
|
||||
|
|
|
|||
Loading…
Reference in a new issue