2010-03-03 27 views
1

我無法獲得reports_as_sparkline plugin在PostgreSQL上工作(它在SQLite上工作正常)。PostgreSQL特定的錯誤報告_as_sparkline

下面是一個典型的錯誤:

>> Annotation.creations_report 
ActiveRecord::StatementInvalid: PGError: ERROR: operator does not exist: ` character varying 
LINE 1: ... grouping = E'day' AND aggregation = E'count' AND `condition... 
                  ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. 
: SELECT * FROM "reports_as_sparkline_cache" WHERE (model_name = E'Annotation' AND report_name = E'creations' AND grouping = E'day' AND aggregation = E'count' AND `condition` = E'' AND reporting_period >= '2009-11-22') ORDER BY reporting_period ASC LIMIT 100 

的思考?

回答

3

刪除反引號',使用單引號'。在SQL中,只允許使用單引號和雙引號,值爲單引號,數據庫對象如表名,列名等的雙引號。

SELECT * FROM "reports_as_sparkline_cache" WHERE (model_name = E'Annotation' AND report_name = E'creations' AND grouping = E'day' AND aggregation = E'count' AND condition = E'' AND reporting_period >= '2009-11-22') ORDER BY reporting_period ASC LIMIT 100