2009/10/7 Jeremy Evans <[email protected]>

>
> On Oct 7, 10:42 am, Christer Nilsson <[email protected]>
> wrote:
>  > I expected the sql statement:
> >
> > SELECT * FROM Item WHERE startDate <= '2009-09-09'
> >
> > by using:
> >
> > Item.filter(:startDate <= '2009-09-09')
> >
> > startDate is declared varchar(20)    (legacy stuff)
> >
> > but got the error
> >
> > `<=': comparison of String with :startDate failed (ArgumentError)
> >
> > Is it not possible to compare strings in Sequel?
>
> I'll take a wild guess that you are using ruby 1.9, which defines
> Symbol#<=.   Sequel doesn't override methods defined by ruby, so you
> can't use that syntax on 1.9.  You can do one of the following:
>
>  Item.filter{startDate <= '2009-09-09'}
>  Item.filter(:startDate.sql_string <= '2009-09-09')
>
> Jeremy
>
No, I'm using 1.8.6.

:createdDate is declared varchar(20)   (legacy stuff)
options[:createdDate] = '2009-09-09'

This works:
      expr = expr & (:createdDate <= options[:createdDate])
      expr = expr & (:createdDate >= options[:createdDate])
This doesn't:
      expr = expr & (options[:createdDate] >=
:createdDate)                      # `>=': comparison of String with
:createdDate failed (ArgumentError)
      expr = expr & (options[:createdDate] <=
:createdDate)                      # `<=': comparison of String with
:createdDate failed (ArgumentError)
      expr = expr & (options[:createdDate].sql_string >= :createdDate)
# sql_string not a method
      expr = expr & (options[:createdDate] >= :createdDate.sql_string)
# sql_string not a method
So, there is a workaround, but I'm still confused.

Christer

--~--~---------~--~----~------------~-------~--~----~
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