Permalink
Browse files

minor speedups + forward-compat syntax

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7471 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 095f458 commit 54a6ed148248b31bee5823d4dd55675edf018e34 @jeremy jeremy committed Sep 13, 2007
@@ -1156,22 +1156,27 @@ def add_order!(sql, order, scope = :auto)
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 @@ def ensure_proper_type
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
@@ -112,8 +112,8 @@ def add_limit_offset!(sql, options)
# 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
@@ -573,8 +573,8 @@ class Cursor #:nodoc:
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)
@@ -54,8 +54,8 @@ def tables(stream)
@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
@@ -321,8 +321,8 @@ def condition_block?(condition)
# 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)
No changes.

0 comments on commit 54a6ed1

Please sign in to comment.