forked from brynary/arel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding default limits when there is an offset for sqlite and mysql [#…
…5316 state:resolved]
- Loading branch information
1 parent
4041d7d
commit e42506f
Showing
9 changed files
with
75 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
module Arel | |||
module Visitors | |||
class SQLite < Arel::Visitors::ToSql | |||
private | |||
def visit_Arel_Nodes_SelectStatement o | |||
o.limit = -1 if o.offset && !o.limit | |||
super | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,21 @@ | |||
require 'helper' | |||
|
|||
module Arel | |||
module Visitors | |||
describe 'the mysql visitor' do | |||
before do | |||
@visitor = MySQL.new Table.engine | |||
end | |||
|
|||
### | |||
# :'( | |||
# http://dev.mysql.com/doc/refman/5.0/en/select.html#id3482214 | |||
it 'defaults limit to 18446744073709551615' do | |||
stmt = Nodes::SelectStatement.new | |||
stmt.offset = Nodes::Offset.new(1) | |||
sql = @visitor.accept(stmt) | |||
sql.must_be_like "SELECT LIMIT 18446744073709551615 OFFSET 1" | |||
end | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,18 @@ | |||
require 'helper' | |||
|
|||
module Arel | |||
module Visitors | |||
describe 'the sqlite visitor' do | |||
before do | |||
@visitor = SQLite.new Table.engine | |||
end | |||
|
|||
it 'defaults limit to -1' do | |||
stmt = Nodes::SelectStatement.new | |||
stmt.offset = Nodes::Offset.new(1) | |||
sql = @visitor.accept(stmt) | |||
sql.must_be_like "SELECT LIMIT -1 OFFSET 1" | |||
end | |||
end | |||
end | |||
end |