diff options
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/table.rb | 4 | ||||
-rw-r--r-- | lib/arel/visitors.rb | 3 | ||||
-rw-r--r-- | lib/arel/visitors/mysql.rb | 7 | ||||
-rw-r--r-- | lib/arel/visitors/sqlite.rb | 11 |
4 files changed, 25 insertions, 0 deletions
diff --git a/lib/arel/table.rb b/lib/arel/table.rb index 171d165bc2..61210dae76 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -80,6 +80,10 @@ module Arel from(self).take amount end + def skip amount + from(self).skip amount + end + def having expr from(self).having expr end diff --git a/lib/arel/visitors.rb b/lib/arel/visitors.rb index 01c6647039..5d4c6084b2 100644 --- a/lib/arel/visitors.rb +++ b/lib/arel/visitors.rb @@ -1,5 +1,6 @@ require 'arel/visitors/visitor' require 'arel/visitors/to_sql' +require 'arel/visitors/sqlite' require 'arel/visitors/postgresql' require 'arel/visitors/mysql' require 'arel/visitors/oracle' @@ -15,6 +16,8 @@ module Arel 'mysql' => Arel::Visitors::MySQL, 'mysql2' => Arel::Visitors::MySQL, 'oracle_enhanced' => Arel::Visitors::Oracle, + 'sqlite' => Arel::Visitors::SQLite, + 'sqlite3' => Arel::Visitors::SQLite, } ENGINE_VISITORS = Hash.new do |hash, engine| diff --git a/lib/arel/visitors/mysql.rb b/lib/arel/visitors/mysql.rb index 0c94ee1b27..594fd5504a 100644 --- a/lib/arel/visitors/mysql.rb +++ b/lib/arel/visitors/mysql.rb @@ -2,6 +2,13 @@ module Arel module Visitors class MySQL < Arel::Visitors::ToSql private + ### + # :'( + # http://dev.mysql.com/doc/refman/5.0/en/select.html#id3482214 + def visit_Arel_Nodes_SelectStatement o + o.limit = 18446744073709551615 if o.offset && !o.limit + super + end def visit_Arel_Nodes_UpdateStatement o [ diff --git a/lib/arel/visitors/sqlite.rb b/lib/arel/visitors/sqlite.rb new file mode 100644 index 0000000000..c45160851d --- /dev/null +++ b/lib/arel/visitors/sqlite.rb @@ -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 |