Skip to content

Commit 1914baa

Browse files
Erik Brynmetaskills
authored andcommitted
added test for prior fix
1 parent b43eaa9 commit 1914baa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/cases/offset_and_limit_test_sqlserver.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def setup
4141

4242
setup do
4343
@select_sql = 'SELECT * FROM books'
44+
@subquery_select_sql = 'SELECT *, (SELECT TOP 1 id FROM books) AS book_id FROM books'
4445
@books = (1..10).map {|i| Book.create!}
4546
end
4647

@@ -75,6 +76,10 @@ def setup
7576
assert_raise(ArgumentError) { @connection.add_limit_offset!(@select_sql, options) }
7677
end
7778

79+
should 'not create invalid SQL with subquery SELECTs with TOP' do
80+
options = { :limit => 5, :offset => 1 }
81+
assert_nothing_raised(ActiveRecord::StatementInvalid) { @connection.add_limit_offset!(@subquery_select_sql, options) }
82+
end
7883
end
7984

8085

0 commit comments

Comments
 (0)