Question

I'm running postgres 9 on mac lion... on a rails 3.2.3 web app.

I am querying a table for an entry called errors_rates_last_updated_at, which doesn't exist as of yet. So when I type the following in the rails console:

a = Settings.errors_rate_last_updated_at

I get a = 0000-01-01 00:00:00 -0800 . Fair enough.

Then when I query the Model with this date, with

 Error.where('most_recent_notice_at > ?', a)

I get this error:

ActiveRecord::StatementInvalid: PG::Error: ERROR:  date/time field value out of range: "0000-01-01 08:00:00.000000"

Could someone help me figure out what's going on? Thanks!

Was it helpful?

Solution

Rails is using a MySQL-ism that isn't valid on Pg. Zero timestamps are not permitted.

regress=# SELECT CAST('0000-01-01 08:00:00.000000' AS date);
ERROR:  date/time field value out of range: "0000-01-01 08:00:00.000000"
LINE 1: SELECT CAST('0000-01-01 08:00:00.000000' AS date);

To understand more about how you're getting to that point you would need to enable query logging - either in PostgreSQL or rails - and find out what query caused the exception.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top