looser_typecasting.rb

lib/sequel/extensions/looser_typecasting.rb
Last Update: 2022-09-22 15:08:16 -0700

The LooserTypecasting extension loosens the default database typecasting for the following types:

:float

use to_f instead of Float()

:integer

use to_i instead of Integer()

:decimal

use 0.0 for unsupported strings

:string

silently allow hash and array conversion to string

This also removes bytesize checks for string inputs for float, integer and decimal conversions.

To load the extension into the database:

DB.extension :looser_typecasting

Related module: Sequel::LooserTypecasting