From c4233a0eaeceba0800990a4ae7eb2ab52a15c737 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 7 Jul 2006 17:40:22 +0000 Subject: PostgreSQL: correctly quote microseconds in timestamps. Closes #5641. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4579 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/CHANGELOG | 2 ++ .../lib/active_record/connection_adapters/postgresql_adapter.rb | 2 +- activerecord/test/base_test.rb | 1 + activerecord/test/fixtures/topics.yml | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) (limited to 'activerecord') diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 20b5a7265a..b98d44e802 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* PostgreSQL: correctly quote microseconds in timestamps. #5641 [rick@rickbradley.com] + * Clearer has_one/belongs_to model names (account has_one :user). #5632 [matt@mattmargolis.net] * Oracle: use nonblocking queries if allow_concurrency is set, fix pessimistic locking, don't guess date vs. time by default (set OracleAdapter.emulate_dates = true for the old behavior), adapter cleanup. #5635 [schoenm@earthlink.net] diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 745e3a45e3..a5af4ee821 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -125,7 +125,7 @@ module ActiveRecord end def quoted_date(value) - value.strftime("%Y-%m-%d %H:%M:%S.#{value.usec}") + value.strftime("%Y-%m-%d %H:%M:%S.#{sprintf("%06d", value.usec)}") end diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb index 9d010c813a..6ccf14af1b 100755 --- a/activerecord/test/base_test.rb +++ b/activerecord/test/base_test.rb @@ -320,6 +320,7 @@ class BasicsTest < Test::Unit::TestCase if current_adapter?(:PostgreSQLAdapter) assert_equal 11, Topic.find(1).written_on.sec assert_equal 223300, Topic.find(1).written_on.usec + assert_equal 9900, Topic.find(2).written_on.usec end end diff --git a/activerecord/test/fixtures/topics.yml b/activerecord/test/fixtures/topics.yml index e78c0e1b3d..e61d17c00c 100644 --- a/activerecord/test/fixtures/topics.yml +++ b/activerecord/test/fixtures/topics.yml @@ -14,7 +14,7 @@ second: id: 2 title: The Second Topic's of the day author_name: Mary - written_on: 2003-07-15t15:28:00.00+01:00 + written_on: 2003-07-15t15:28:00.0099+01:00 content: Have a nice day approved: true replies_count: 0 -- cgit v1.2.3