diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-03-31 05:41:37 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-04-05 22:50:01 +0900 |
commit | 83c337a4ab675a137397f83b74e6e0132c358164 (patch) | |
tree | 8aa0d44995af7e3f81315d8c5c7014f50679faee /activerecord | |
parent | e9a8c387885bc88d53221bb7fd25198b11926ec0 (diff) | |
download | rails-83c337a4ab675a137397f83b74e6e0132c358164.tar.gz rails-83c337a4ab675a137397f83b74e6e0132c358164.tar.bz2 rails-83c337a4ab675a137397f83b74e6e0132c358164.zip |
Move `quoted_date`, `quote_string` and `quote_table_name_for_assignment` methods to `Quoting` module
Diffstat (limited to 'activerecord')
4 files changed, 16 insertions, 22 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index 57d2477eac..1a24b64984 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -162,18 +162,6 @@ module ActiveRecord raise NotImplementedError end - #-- - # QUOTING ================================================== - #++ - - def quoted_date(value) - if supports_datetime_with_precision? - super - else - super.sub(/\.\d{6}\z/, '') - end - end - # REFERENTIAL INTEGRITY ==================================== def disable_referential_integrity #:nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb b/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb index c19889dcd0..bc0608d16e 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/quoting.rb @@ -26,6 +26,14 @@ module ActiveRecord 0 end + def quoted_date(value) + if supports_datetime_with_precision? + super + else + super.sub(/\.\d{6}\z/, '') + end + end + private QUOTED_TRUE, QUOTED_FALSE = '1', '0' diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb b/activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb index faf2f375dc..d3a91f73c8 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3/quoting.rb @@ -2,6 +2,14 @@ module ActiveRecord module ConnectionAdapters module SQLite3 module Quoting # :nodoc: + def quote_string(s) + @connection.class.quote(s) + end + + def quote_table_name_for_assignment(table, attr) + quote_column_name(attr) + end + def quote_column_name(name) @quoted_column_names[name] ||= %Q("#{super.gsub('"', '""')}") end diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 5c8e428bef..786b0ab2ed 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -176,16 +176,6 @@ module ActiveRecord true end - # QUOTING ================================================== - - def quote_string(s) #:nodoc: - @connection.class.quote(s) - end - - def quote_table_name_for_assignment(table, attr) - quote_column_name(attr) - end - #-- # DATABASE STATEMENTS ====================================== #++ |