Thanks for the quick reply.
Seems the simple fix is to change the column type in sqlite3. Sequel's
behaviour makes perfect sense to me. And will consider the issue closed.
FYI, This issue has had me confused for a while. As the initial app design
request was to only use integers. Users started using decimals for more
precise sorting. Then users inform me that it stopped working about 6
months ago. Because of other priorities, this issue was moved forward.
According to my git history, my first commit was version Sequel 4.41. Now I
am using version 5.31
On Friday, June 12, 2020 at 11:07:11 AM UTC-4 Jeremy Evans wrote:
> On Friday, June 12, 2020 at 7:59:29 AM UTC-7, Jeremy Evans wrote:
>>
>> On Friday, June 12, 2020 at 7:44:11 AM UTC-7, Remtech Industries wrote:
>>>
>>> I created a column in my table in sqlite3 years ago.
>>> Migration:
>>> Integer :priority, null: false, default: 2000
>>>
>>> And I was able to use decimal in that column for years without issue.
>>>
>>> Recently, sequel will read 1.5 as 1.
>>>
>>> Was there an upgrade that changed this behaviour? Also, what is a
>>> recommendation to resolve this?
>>>
>>
>> Sequel assumes that if your column type is "integer", that the values
>> should be integers, and converts the value to integer. The fact that
>> SQLite does not enforce column types is probably it's biggest flaw
>> (followed by lack of common types such as date and inability to make most
>> table modifications).
>>
>> I think Sequel's behavior in this case hasn't changed significantly
>> recently. What version of Sequel were you using that wasn't doing the
>> conversion? I checked and even Sequel 4 has this behavior.
>>
>
> I tested and Sequel 2.6.0, released in 2008, does this conversion.
>
> gem 'sequel', '=2.6.0'
> require 'sequel'
> DB = Sequel.connect('sqlite:/')
> DB.create_table(:t){column :priority, Integer, :null => false, :default =>
> 2000}
> DB[:t].insert(1.5)
> DB[:t].all
> # => [{:priority=>1}]
>
> 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 view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/3ab82f65-bb09-49e3-9bf7-02c6f775aed3n%40googlegroups.com.