Skip to content

Commit 226e6fe

Browse files
committed
More ARel done.
1 parent 81ebfcb commit 226e6fe

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

lib/arel/visitors/sqlserver.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,13 @@ def rowtable_projections(o)
262262
end
263263

264264
def rowtable_orders(o)
265+
core = o.cores.first
265266
if !o.orders.empty?
266267
o.orders
267268
elsif join_in_select_statement?(o)
268-
raise 'TODO: rowtable_orders - join_in_select_statement?(o)'
269-
# table_names_from_select_clauses.map { |tn| quote("#{tn}.#{pk_for_table(tn)}") }
269+
[core.from.primary_key.asc]
270270
else
271-
tn = table_name_from_select_statement(o)
272-
[Arel::Table.new(tn, @engine).primary_key.asc]
271+
[core.from.primary_key.asc]
273272
end.reverse.uniq.reverse
274273
end
275274

test/cases/scratch_test_sqlserver.rb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,8 @@ class ScratchTestSqlserver < ActiveRecord::TestCase
2626
:developers, :projects, :developers_projects
2727

2828
should 'pass' do
29-
Post.send(:with_scope, :find => { :conditions => "1=1" }) do
30-
posts = authors(:david).posts.find(:all,
31-
:include => :comments,
32-
:conditions => "comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment'",
33-
:limit => 2
34-
)
35-
assert_equal 2, posts.size
36-
37-
count = Post.count(
38-
:include => [ :comments, :author ],
39-
:conditions => "authors.name = 'David' AND (comments.body like 'Normal%' OR comments.#{QUOTED_TYPE}= 'SpecialComment')",
40-
:limit => 2
41-
)
42-
assert_equal count, posts.size
43-
end
29+
posts = Post.count(:all, :include => [ :author, :comments ], :limit => 2, :offset => 10, :conditions => [ "authors.name = ?", 'David' ])
30+
assert_equal 0, posts
4431
end
4532

4633

0 commit comments

Comments
 (0)