Permalink
Browse files

Make to private the visibility of `_quote` and `_type_cast`

  • Loading branch information...
kamipo committed Mar 30, 2016
1 parent cd736db commit c5131b62b7df8aff07875b76131ec03af360fb35
@@ -1,6 +1,7 @@
require 'active_record/connection_adapters/abstract_adapter'
require 'active_record/connection_adapters/mysql/column'
require 'active_record/connection_adapters/mysql/explain_pretty_printer'
require 'active_record/connection_adapters/mysql/quoting'
require 'active_record/connection_adapters/mysql/schema_creation'
require 'active_record/connection_adapters/mysql/schema_definitions'
require 'active_record/connection_adapters/mysql/schema_dumper'
@@ -11,6 +12,7 @@
module ActiveRecord
module ConnectionAdapters
class AbstractMysqlAdapter < AbstractAdapter
include MySQL::Quoting
include MySQL::ColumnDumper
include Savepoints
@@ -165,14 +167,6 @@ def error_number(exception) # :nodoc:
# QUOTING ==================================================
def _quote(value) # :nodoc:
if value.is_a?(Type::Binary::Data)
"x'#{value.hex}'"
else
super
end
end
def quote_column_name(name) #:nodoc:
@quoted_column_names[name] ||= "`#{name.to_s.gsub('`', '``')}`"
end
@@ -0,0 +1,17 @@
module ActiveRecord
module ConnectionAdapters
module MySQL
module Quoting # :nodoc:
private
def _quote(value)
if value.is_a?(Type::Binary::Data)
"x'#{value.hex}'"
else
super
end
end
end
end
end
end
@@ -0,0 +1,32 @@
module ActiveRecord
module ConnectionAdapters
module SQLite3
module Quoting # :nodoc:
private
def _quote(value)
if value.is_a?(Type::Binary::Data)
"x'#{value.hex}'"
else
super
end
end
def _type_cast(value)
case value
when BigDecimal
value.to_f
when String
if value.encoding == Encoding::ASCII_8BIT
super(value.encode(Encoding::UTF_8))
else
super
end
else
super
end
end
end
end
end
end
@@ -1,6 +1,7 @@
require 'active_record/connection_adapters/abstract_adapter'
require 'active_record/connection_adapters/statement_pool'
require 'active_record/connection_adapters/sqlite3/explain_pretty_printer'
require 'active_record/connection_adapters/sqlite3/quoting'
require 'active_record/connection_adapters/sqlite3/schema_creation'
gem 'sqlite3', '~> 1.3.6'
@@ -49,6 +50,8 @@ module ConnectionAdapters #:nodoc:
# * <tt>:database</tt> - Path to the database file.
class SQLite3Adapter < AbstractAdapter
ADAPTER_NAME = 'SQLite'.freeze
include SQLite3::Quoting
include Savepoints
NATIVE_DATABASE_TYPES = {
@@ -176,30 +179,6 @@ def supports_explain?
# QUOTING ==================================================
def _quote(value) # :nodoc:
case value
when Type::Binary::Data
"x'#{value.hex}'"
else
super
end
end
def _type_cast(value) # :nodoc:
case value
when BigDecimal
value.to_f
when String
if value.encoding == Encoding::ASCII_8BIT
super(value.encode(Encoding::UTF_8))
else
super
end
else
super
end
end
def quote_string(s) #:nodoc:
@connection.class.quote(s)
end

0 comments on commit c5131b6

Please sign in to comment.