mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
minor speedups + forward-compat syntax
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7471 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
095f458b7a
commit
54a6ed1482
6 changed files with 24 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue