aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2014-12-11 19:45:01 +0900
committerRyuta Kamizono <kamipo@gmail.com>2014-12-11 19:45:01 +0900
commitcb07e63ba8d2d6a5aa13ce4799544fd5b413d9ff (patch)
tree33556835bffeefac45ddf1217176edd8560a7c53 /activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
parent81e940c313b6924915ca77a0f3af66332c9f0b1f (diff)
downloadrails-cb07e63ba8d2d6a5aa13ce4799544fd5b413d9ff.tar.gz
rails-cb07e63ba8d2d6a5aa13ce4799544fd5b413d9ff.tar.bz2
rails-cb07e63ba8d2d6a5aa13ce4799544fd5b413d9ff.zip
Refactor `quoted_date`
Move microseconds formatting to `AbstractAdapter`.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb10
1 files changed, 3 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
index 991c41327f..607848884b 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
@@ -43,16 +43,12 @@ module ActiveRecord
# Quote date/time values for use in SQL input. Includes microseconds
# if the value is a Time responding to usec.
def quoted_date(value) #:nodoc:
- result = super
- if value.acts_like?(:time) && value.respond_to?(:usec)
- result = "#{result}.#{sprintf("%06d", value.usec)}"
- end
-
if value.year <= 0
bce_year = format("%04d", -value.year + 1)
- result = result.sub(/^-?\d+/, bce_year) + " BC"
+ super.sub(/^-?\d+/, bce_year) + " BC"
+ else
+ super
end
- result
end
# Does not quote function default values for UUID columns