diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 4dfd4a26b1..badd4b6b18 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1156,22 +1156,27 @@ module ActiveRecord #:nodoc: sql << " ORDER BY #{scoped_order}" if scoped_order end end - - def add_group!(sql, group, scope = :auto) - scope = scope(:find) if :auto == scope - scoped_group = scope[:group] if scope + def add_group!(sql, group, scope = :auto) if group sql << " GROUP BY #{group}" - elsif scoped_group - sql << " GROUP BY #{scoped_group}" - end + else + scope = scope(:find) if :auto == scope + if scope && (scoped_group = scope[:group]) + sql << " GROUP BY #{scoped_group}" + end + end end # The optional scope argument is for the current :find scope. def add_limit!(sql, options, scope = :auto) scope = scope(:find) if :auto == scope - options = options.reverse_merge(:limit => scope[:limit], :offset => scope[:offset]) if scope + + if scope + options[:limit] ||= scope[:limit] + options[:offset] ||= scope[:offset] + end + connection.add_limit_offset!(sql, options) end @@ -1994,9 +1999,9 @@ module ActiveRecord #:nodoc: def convert_number_column_value(value) case value - when FalseClass: 0 - when TrueClass: 1 - when '': nil + when FalseClass; 0 + when TrueClass; 1 + when ''; nil else value end end diff --git a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb index e8f133848d..75dafe61da 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb @@ -112,8 +112,8 @@ module ActiveRecord # add_lock! 'SELECT * FROM suppliers', :lock => ' FOR UPDATE' def add_lock!(sql, options) case lock = options[:lock] - when true: sql << ' FOR UPDATE' - when String: sql << " #{lock}" + when true; sql << ' FOR UPDATE' + when String; sql << " #{lock}" end end diff --git a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb index 701d8f6c27..58544f4cb2 100644 --- a/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb @@ -573,8 +573,8 @@ begin alias :define_a_column_pre_ar :define_a_column def define_a_column(i) case do_ocicall(@ctx) { @parms[i - 1].attrGet(OCI_ATTR_DATA_TYPE) } - when 8 : @stmt.defineByPos(i, String, 65535) # Read LONG values - when 187 : @stmt.defineByPos(i, OraDate) # Read TIMESTAMP values + when 8; @stmt.defineByPos(i, String, 65535) # Read LONG values + when 187; @stmt.defineByPos(i, OraDate) # Read TIMESTAMP values when 108 if @parms[i - 1].attrGet(OCI_ATTR_TYPE_NAME) == 'XMLTYPE' @stmt.defineByPos(i, String, 65535) diff --git a/activerecord/lib/active_record/schema_dumper.rb b/activerecord/lib/active_record/schema_dumper.rb index 7fe5f26daf..618961b106 100644 --- a/activerecord/lib/active_record/schema_dumper.rb +++ b/activerecord/lib/active_record/schema_dumper.rb @@ -54,8 +54,8 @@ HEADER @connection.tables.sort.each do |tbl| next if ["schema_info", ignore_tables].flatten.any? do |ignored| case ignored - when String: tbl == ignored - when Regexp: tbl =~ ignored + when String; tbl == ignored + when Regexp; tbl =~ ignored else raise StandardError, 'ActiveRecord::SchemaDumper.ignore_tables accepts an array of String and / or Regexp values.' end diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index c5c3a2b84a..75b752db6e 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -321,8 +321,8 @@ module ActiveRecord # whether or not to validate the record. See #validates_each. def evaluate_condition(condition, record) case condition - when Symbol: record.send(condition) - when String: eval(condition, record.send(:binding)) + when Symbol; record.send(condition) + when String; eval(condition, record.send(:binding)) else if condition_block?(condition) condition.call(record) diff --git a/activerecord/test/mixin_nested_set_test.rb b/activerecord/test/mixin_nested_set_test.rb deleted file mode 100644 index e69de29bb2..0000000000