On Feb 10, 3:21 pm, Cheese  Lottery <[email protected]> wrote:
> It turns out that with 1/0s as booleans, Sequel's default behavior
> only works sometimes:
>
> DB[:some_table].where(:some_column) or
> DB[:some_table].where(~:some_column) works
> DB[:some_table].where(:some_column => boolean) does not work

It works here with your code:

  DB[:a].where(:b=>true)
  # SELECT * FROM `a` WHERE (`b` = 1)
  DB[:a].where(:b=>false)
  # SELECT * FROM `a` WHERE (`b` = 0)

It doesn't work by default as Sequel uses t/f for boolean by default,
which can't change for backwards compatibility purposes.  I'll
certainly consider a patch that adds a simple switch to change the
default of t/f to 1/0 (to the shared sqlite adapter).  For the native
sqlite adapter, in order to get booleans returned when the column
value is stored as an integer, you'd need to refactor the type
translation code.  It would cause a performance hit, as you'd have to
add some additional checks to the inner loop.

> It might be worth documenting this somewhere, as SQLite's
> documentation tells users to store booleans as 1 and 
> 0:http://sqlite.org/datatype3.html

I agree.  If you can think of the appropriate place, I'll be happy to
add some documentation.

Thanks,
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.

Reply via email to