She*_* Wu 4 postgresql ruby-on-rails
我在mac lion上运行postgres 9 ...在rails 3.2.3 web app上运行.
我正在查询表名为errors_rates_last_updated_at的条目,该条目目前尚不存在.所以当我在rails控制台中键入以下内容时:
a = Settings.errors_rate_last_updated_at
Run Code Online (Sandbox Code Playgroud)
我得到= 0000-01-01 00:00:00 -0800.很公平.
然后当我用这个日期查询模型时,用
Error.where('most_recent_notice_at > ?', a)
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
ActiveRecord::StatementInvalid: PG::Error: ERROR: date/time field value out of range: "0000-01-01 08:00:00.000000"
Run Code Online (Sandbox Code Playgroud)
有人可以帮我弄清楚发生了什么吗?谢谢!
Rails使用的是在Pg上无效的MySQL-ism.不允许零时间戳.
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);
Run Code Online (Sandbox Code Playgroud)
要了解有关如何达到这一点的更多信息,您需要启用查询日志记录 - 无论是在PostgreSQL还是rails中 - 并找出导致异常的查询.
| 归档时间: |
|
| 查看次数: |
8043 次 |
| 最近记录: |