我有人物模型
=> Person(id: integer, name: string, created_at: datetime, updated_at: datetime)
我在查询名字属性但是有一个错字:
2.2.0 :012 > Person.where(namee: [])
Person Load (0.8ms) SELECT "people".* FROM "people" WHERE 1=0
=> #<ActiveRecord::Relation []>
在上面的查询中有一个拼写错误(name =&gt; namee),但Rails没有引发错误, WHERE 1 = 0 查询已执行。
但是当我使用带有一些值的数组运行它时,它会抛出未定义的列错误。
2.2.0 :013 > Person.where(namee: ["din"])
Person Load (1.9ms) SELECT "people".* FROM "people" WHERE "people"."namee" = 'din'
PG::UndefinedColumn: ERROR: column people.namee does not exist
LINE 1: SELECT "people".* FROM "people" WHERE "people"."namee" = 'di...
这是Rails中的错误吗?我认为即使对于空白数组也应该引发未定义的列错误。