Skip to content

Commit

Permalink
Merge pull request #1203 from yahonda/bind_param_warnings
Browse files Browse the repository at this point in the history
`bind_param` arity change, not to take column
  • Loading branch information
yahonda committed Feb 23, 2017
2 parents 9f324ef + fb444b7 commit d990f94
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,7 @@ def bind_params(*bind_vars)
end
end

def bind_param(position, value, column = nil)
if column
ActiveSupport::Deprecation.warn(<<-MSG.squish)
*******************************************************
Passing a column to `bind_param` will be deprecated.
`type_casted_binds` should be already type casted
so that `bind_param` should not need to know column.
*******************************************************
MSG
end

def bind_param(position, value)
case value
when Integer
@raw_statement.setLong(position, value)
Expand All @@ -374,14 +364,10 @@ def bind_param(position, value, column = nil)
# TODO: Really needed or not
@raw_statement.setTimestamp(position, value)
when NilClass
if column && column.object_type?
@raw_statement.setNull(position, java.sql.Types::STRUCT, column.sql_type)
else
# TODO: currently nil is always bound as NULL with VARCHAR type.
# When nils will actually be used by ActiveRecord as bound parameters
# then need to pass actual column type.
@raw_statement.setNull(position, java.sql.Types::VARCHAR)
end
# TODO: currently nil is always bound as NULL with VARCHAR type.
# When nils will actually be used by ActiveRecord as bound parameters
# then need to pass actual column type.
@raw_statement.setNull(position, java.sql.Types::VARCHAR)
else
raise ArgumentError, "Don't know how to bind variable with type #{value.class}"
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,16 @@ def bind_params(*bind_vars)
end
end

def bind_param(position, value, column = nil)
if column
ActiveSupport::Deprecation.warn(<<-MSG.squish)
*******************************************************
Passing a column to `bind_param` will be deprecated.
`type_casted_binds` should be already type casted
so that `bind_param` should not need to know column.
*******************************************************
MSG
end

if column && column.object_type?
@raw_cursor.bind_param(position, value, :named_type, column.sql_type)
def bind_param(position, value)
case value
when ActiveRecord::OracleEnhanced::Type::Raw
@raw_cursor.bind_param(position, ActiveRecord::ConnectionAdapters::OracleEnhanced::Quoting.encode_raw(value))
when ActiveModel::Type::Decimal
@raw_cursor.bind_param(position, BigDecimal.new(value.to_s))
when NilClass
@raw_cursor.bind_param(position, nil, String)
else
case value
when ActiveRecord::OracleEnhanced::Type::Raw
@raw_cursor.bind_param(position, ActiveRecord::ConnectionAdapters::OracleEnhanced::Quoting.encode_raw(value))
when ActiveModel::Type::Decimal
@raw_cursor.bind_param(position, BigDecimal.new(value.to_s))
when NilClass
@raw_cursor.bind_param(position, nil, String)
else
@raw_cursor.bind_param(position, value)
end
@raw_cursor.bind_param(position, value)
end
end

Expand Down

0 comments on commit d990f94

Please sign in to comment.