Rails - 2.3.8 数据库 - Postgres(9.2)
活动记录查询无法在双引号中生成表名,即
# this ran fine
Table.find_by_sql('Select * from "Table" Limit 1')
Sql generated - Select * from "Table" Limit 1
但问题来了,
Table.find(:first)
Sql generated - Select * from Table Limit 1 (Clearly noticed that table not in double quotes)
活动记录显示错误
ActiveRecord::StatementInvalid: RuntimeError: ERROR
C42P01 Mrelation "Table" does not exist
P15 Fparse_relation.c L864
RparserOpenTable: SELECT * FROM Table LIMIT 1
我觉得postgresql适配器无法用双引号生成tablename。
答案 0 :(得分:-1)
我从来没有机会在Postgres上工作。但我有一个解决方法。请尝试如下:
table_name = '"Table"'
table_name.find(:first)
我没有在我的机器上尝试这个,因为我没有所需的设置。我希望它能奏效。