Rails:从MySQL转换为PostGres会中断Geokit距离计算吗? [英] Rails: Converting from MySQL to PostGres breaks Geokit Distance Calculations?

查看:104
本文介绍了Rails:从MySQL转换为PostGres会中断Geokit距离计算吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将数据库从MySQL切换到了PostGres.我也使用GeoKit.当我使用已经播种的新数据库启动应用程序时,出现以下错误:

I recently switched my database from MySQL to PostGres. I also use GeoKit. When I started my app up with the new database already seeded, I get the following error:

PGError: ERROR:  function radians(character varying) does not exist
LINE 1: ...COS(0.661045389762993)*COS(-2.12957994527573)*COS(RADIANS(ti...
                                                         ^
HINT:  No function matches the given name and argument types. You might 
need to add explicit type casts.

任何人都知道为什么现在这种情况会中断吗?我知道GeoKit仍然可以工作,因为在播种数据库时,它仍在对每张票证进行模型中的地理编码,只是无法正确计算距离.

Anyone know why this is breaking now? I know GeoKit still works because it's still performing the geocoding in the model per ticket when the database is seeded, it just won't do the distance calculations correctly.

推荐答案

对于那些在搜索中查找此答案的人,问题在于Postgresql要求lat,lng列为十进制或至少非字符串,而MySQL允许两者都使用.

For those looking up this answer in the search, the problem is that Postgresql requires the lat, lng columns to be decimal or at least non-string whereas MySQL allows using both.

这篇关于Rails:从MySQL转换为PostGres会中断Geokit距离计算吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆