Permalink
Browse files

add sqlite method; fix chubbies cukes

  • Loading branch information...
1 parent 607013b commit 5348c7220971e9f67956787546bec2a74cbbe037 @maxwell maxwell committed Sep 30, 2011
Showing with 12 additions and 4 deletions.
  1. +1 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +4 −0 config/environment.rb
  4. +5 −4 lib/diaspora/user/querying.rb
View
@@ -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
View
@@ -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 @@ def visible_posts(opts = {})
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)

0 comments on commit 5348c72

Please sign in to comment.