On Wednesday, April 29, 2015 at 6:56:48 AM UTC-7, Rohit Amarnath wrote:
>
> I have a SQLite table that is defined as:
>
> DB.create_table :airport_codes do
> column :airport_code, :text
> column :airport_latitude, :real
> column :airport_longitude, :real
> end
>
> The row stored is:
>
> {:airport_code=>"DXB",
> :airport_latitude=>25.25,
> :airport_longitude=>55.366667
> }
>
> Row returned by Sequel is:
>
> {:airport_code=>"DXB",
> :airport_latitude=>25.25,
> :airport_longitude=>55.366668701171875
> }
>
> How can I have it return exactly what is in the database without the
> precision change?
>
I can't replicate this issue:
$ ruby bin/sequel -E sqlite:/
I, [2015-04-29T07:53:04.352789 #4109] INFO -- : (0.001867s) PRAGMA
foreign_keys = 1
I, [2015-04-29T07:53:04.352996 #4109] INFO -- : (0.000055s) PRAGMA
case_sensitive_like = 1
Your database is stored in DB...
irb(main):001:0> DB.create_table :airport_codes do
irb(main):002:1* column :airport_code, :text
irb(main):003:1> column :airport_latitude, :real
irb(main):004:1> column :airport_longitude, :real
irb(main):005:1> end
I, [2015-04-29T07:53:09.174162 #4109] INFO -- : (0.001155s) CREATE TABLE
`airport_codes` (`airport_code` text, `airport_latitude` real,
`airport_longitude` real)
=> nil
irb(main):006:0> DB[:airport_codes].insert(
irb(main):007:1* {:airport_code=>"DXB",
irb(main):008:2* :airport_latitude=>25.25,
irb(main):009:2* :airport_longitude=>55.366667
irb(main):010:2> })
I, [2015-04-29T07:53:32.311542 #4109] INFO -- : (0.000511s) SELECT
sqlite_version()
I, [2015-04-29T07:53:32.312180 #4109] INFO -- : (0.000291s) INSERT INTO
`airport_codes` (`airport_code`, `airport_latitude`, `airport_longitude`)
VALUES ('DXB', 25.25, 55.366667)
=> 1
irb(main):011:0> DB[:airport_codes].all
I, [2015-04-29T07:53:39.567679 #4109] INFO -- : (0.000283s) SELECT * FROM
`airport_codes`
=> [{:airport_code=>"DXB", :airport_latitude=>25.25,
:airport_longitude=>55.366667}]
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.