Jeremy,

Ah, that makes sense. Though after having played with it it seems it's not
very hard to detect whether or not the specified
string is actually converted correctly:

'hello123'.to_f # => 0.0
'h'.to_f           # => 0.0

Based on this you could do something like the following:

input        = '12'
converted = input.to_f

if input !== '0.0' and converted === 0.0
  raise(ArgumentError, '....')
end

Anyway, I'd say go for it!

Yorick

On 13 July 2011 16:59, Jeremy Evans <[email protected]> wrote:

>
>
> On Jul 13, 2:47 am, Yorick Peterse <[email protected]> wrote:
> > Jeremy,
> >
> > While I'm all for this fix, especially since I can't think of any issues
> > with to_i() and to_f() (I might just not know about them),
>
> 'a'.to_i = 0
> 'a'.to_f = 0.0
>
> > I think it's a
> > good idea to provide an
> > extension that makes the code backwards compatible just like you said.
> This
> > would give people the time to either update their code or realize newer
> > versions of
> > Sequel just aren't going to work for certain applications (sometimes
> > updating legacy code just isn't going to work). Just out of curiosity,
> what
> > was your initial
> > motivation for going with Kernel#Integer and Kernel#Float rather than
> using
> > to_f() and to_i()?
>
> Integer('a') # raises ArgumentError
> Float('a') # raises ArgumentError
>
> Note that the looser_typecasting extension makes the database use to_i
> and to_f.
>
> Jeremy
>
> --
> You received this message because you are subscribed to the Google Groups
> "sequel-talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/sequel-talk?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to