Heroku 的点击推动了怪异
我有过使用 Tap 在我的机器和 Heroku 之间移动数据的最奇怪的经历。
它工作正常,只是它似乎在我的地理坐标的小数位后面直接丢失了 0,即 50.0519322 由于某种原因被设置为 50.519322...不知道为什么。
当我从远程位置提取数据时,即。 heroku db:pull... 它工作正常,我的机器上的所有小数位都完好无损,但是,当我将其推回远程服务器时,它会丢失这些零。特别是在小数点后面,尽管我在其他地方还没有注意到它。
起初,我将 lat 和 lng 存储为简单的数字,但将其细化为:
change_column :places, :lat, :numeric, :precision => 15, :scale => 10
change_column :places, :lng, :numeric, :precision => 15, :scale => 10
没有结果,知道发生了什么吗?
从远程服务器上的控制台,我得到的纬度为: ,
#<BigDecimal:2aebcc5967c0,'0.50519322E2',18(18)>
我的机器为:
#<BigDecimal:10232f7c8,'0.50519322E2',12(16)>
这也很奇怪,第二个是因为当我通过视图编辑它时,它显示为 50.0519322 但当我通过控制台执行 to_f 时,它给了我50.519322
服务器和本地计算机都是 postgres,存储为数字。
I have the strangest experience using taps to move data between my machine and Heroku.
It works fine except that it seems to lose 0s directly behind the decimal place for my geo coordinates i.e. 50.0519322 for some reason gets set to 50.519322... no idea why.
When I pull the data from the remote location ie. heroku db:pull... it works fine, all decimal places intact on my machine, however, when I push it back to the remote server it loses these zeros. Especially directly behind the decimal place, though I haven't noticed it elsewhere yet.
At first I was storing the lat and lng as simply numeric but refined it to:
change_column :places, :lat, :numeric, :precision => 15, :scale => 10
change_column :places, :lng, :numeric, :precision => 15, :scale => 10
With no result, any ideas what's going on?
From the console on the remote server I get the lat as being:
#<BigDecimal:2aebcc5967c0,'0.50519322E2',18(18)>
and my machine as:
#<BigDecimal:10232f7c8,'0.50519322E2',12(16)>
which is also odd, the second one because it shows up as 50.0519322 when I edit it through my view but when I do to_f via console it gives me 50.519322
Both server and local machine are postgres, storage as numeric.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来像是 Ruby 中的 BigDecimal bug:
http://blog.ethanvizitei.com/2010 /04/bug-with-bigdecimal-in-ruby-187.html
db:pull
和db:push
最适合开发使用。我建议使用 PGBackups 系统来移动数据,而无需在本地系统和 Heroku 之间进行任何更改:http:// devcenter.heroku.com/articles/pgbackups
This sounds like the BigDecimal bug in Ruby:
http://blog.ethanvizitei.com/2010/04/bug-with-bigdecimal-in-ruby-187.html
db:pull
anddb:push
are best for development use. I recommend using the PGBackups system for moving data without any chance of change between your local system and Heroku:http://devcenter.heroku.com/articles/pgbackups