Permalink
Browse files

More ARel done.

  • Loading branch information...
1 parent 81ebfcb commit 226e6fe47734be0643a3e46014daf6ff9f797d92 @metaskills metaskills committed Jan 15, 2011
Showing with 5 additions and 19 deletions.
  1. +3 −4 lib/arel/visitors/sqlserver.rb
  2. +2 −15 test/cases/scratch_test_sqlserver.rb
@@ -262,14 +262,13 @@ def rowtable_projections(o)
end
def rowtable_orders(o)
+ core = o.cores.first
if !o.orders.empty?
o.orders
elsif join_in_select_statement?(o)
- raise 'TODO: rowtable_orders - join_in_select_statement?(o)'
- # table_names_from_select_clauses.map { |tn| quote("#{tn}.#{pk_for_table(tn)}") }
+ [core.from.primary_key.asc]
else
- tn = table_name_from_select_statement(o)
- [Arel::Table.new(tn, @engine).primary_key.asc]
+ [core.from.primary_key.asc]
end.reverse.uniq.reverse
end
@@ -26,21 +26,8 @@ class ScratchTestSqlserver < ActiveRecord::TestCase
:developers, :projects, :developers_projects
should 'pass' do
- Post.send(:with_scope, :find => { :conditions => "1=1" }) do
- posts = authors(:david).posts.find(:all,
- :include => :comments,
- :conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'",
- :limit => 2
- )
- assert_equal 2, posts.size
-
- count = Post.count(
- :include => [ :comments, :author ],
- :conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')",
- :limit => 2
- )
- assert_equal count, posts.size
- end
+ posts = Post.count(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ])
+ assert_equal 0, posts
end

0 comments on commit 226e6fe

Please sign in to comment.