使用内部查询功能时,我正在通过SQLite3接收SQL Exeption。
ActiveRecord::StatementInvalid (SQLite3::SQLException: no such function: least: SELECT "groups".* FROM "groups" WHERE (groups.lat IS NOT NULL AND groups.lng IS NOT NULL) AND (groups.lat>-0.7228492642679549 AND groups.lat<0.7228492642679549 AND groups.lng>-0.722849264267955 AND groups.lng<0.722849264267955) AND ((
(CASE WHEN groups.lat IS NULL OR groups.lng IS NULL THEN NULL ELSE
(ACOS(least(1,COS(0.0)*COS(0.0)*COS(RADIANS(groups.lat))*COS(RADIANS(groups.lng))+
COS(0.0)*SIN(0.0)*COS(RADIANS(groups.lat))*SIN(RADIANS(groups.lng))+
SIN(0.0)*SIN(RADIANS(groups.lat))))*3963.1899999999996)
END)
<= 50))):
这是通过以下函数在我的用户模型中调用的:
def local_groups
Group.within(50, units: :miles, origin: [lat, lng])
end
查询在浏览器中工作正常,但我设置为api模式。通过react和axios查询时,我在第二个或第三个get请求中遇到了这个问题。一旦发生错误,该错误将一直持续到服务器重新启动。我正在寻求帮助,因为它看起来像个傻瓜。