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/96a017b8-f122-4b3d-9785-e135edc9e3c6o%40googlegroups.com.

Reply via email to