Skip to content

Instantly share code, notes, and snippets.

@sodabrew
Created November 26, 2013 20:47
Show Gist options
  • Save sodabrew/7665924 to your computer and use it in GitHub Desktop.
Save sodabrew/7665924 to your computer and use it in GitHub Desktop.
diff --git a/Gemfile b/Gemfile
index 1422da2..521b4da 100644
--- a/Gemfile
+++ b/Gemfile
@@ -38,7 +38,7 @@ group :test do
end
platforms :mri_19, :mri_20 do
- gem 'debugger'
+ # gem 'debugger'
end
gem 'benchmark-ips'
@@ -55,7 +55,7 @@ platforms :ruby do
gem 'sqlite3', '~> 1.3.6'
group :db do
- gem 'pg', '>= 0.11.0'
+# gem 'pg', '>= 0.11.0'
gem 'mysql', '>= 2.9.0'
gem 'mysql2', '>= 0.3.13'
end
diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
index e790f73..1587eae 100644
--- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb
@@ -77,6 +77,14 @@ module ActiveRecord
@connection.escape(string)
end
+ def quoted_date(value)
+ if value.acts_like?(:time) && value.respond_to?(:usec)
+ "#{super}.#{sprintf("%06d", value.usec)}"
+ else
+ super
+ end
+ end
+
# CONNECTION MANAGEMENT ====================================
def active?
diff --git a/activerecord/test/cases/quoting_test.rb b/activerecord/test/cases/quoting_test.rb
index e2439b9..99ce92b 100644
--- a/activerecord/test/cases/quoting_test.rb
+++ b/activerecord/test/cases/quoting_test.rb
@@ -52,6 +52,11 @@ module ActiveRecord
assert_equal t.to_s(:db), @quoter.quoted_date(t)
end
+ def test_quoted_time_microseconds
+ t = Time.at(946684800.2123)
+ assert_equal "100000.212300", @quoter.quoted_date(t)
+ end
+
def test_quoted_time_utc
with_timezone_config default: :utc do
t = Time.now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment