rails/rails — pull request #12051 by bcherry (2013-08-27 23:50:10+00:00)
Title: ActiveRecord: Include usecs when quoting DateTime in PostgreSQL adapter

The PostgreSQL adapter has a bug where it fails to include the fractional seconds when quoting DateTime values for queries or storage. This causes loss of precision during storage, and also failure during future query operations, like so:

f = Foo.first
Foo.where(:created_at => f.created_at.to_datetime).first.id == f.id # false

This patch ensures the usec are sent when quoting DateTime objects (as they are for Time objects)