Sorry for the newb question here, but I'm having a hard time figuring out 
the syntax for checking equality in a sequel expression.

I have a table "transactions" with corresponding Sequel::Model that has a 
column "timestamp" defined like this:

    column :timestamp, Time, null: false, default: Sequel::CURRENT_TIMESTAMP

I'd like to query something simple like:

    Transaction.where(:timestamp => Date.today)

This doesn't work, though, as the SQL generated is comparing a timestamp 
against a date, so doesn't match. Well, using a block for where I could 
cast this easily enough, and make a query like:

    Transaction.where{ (date(timestamp) > (Date.today - 1)) & 
(date(timestamp) <= (Date.today)) }

This works, but it seems excessively verbose when what I actually want is 
just to use "==" in the block. However if you do:

    Transaction.where{ date(timestamp) == Date.today }

..the query generated is "SELECT * FROM \"transactions\" WHERE false", so I 
guess it's being evaluated before being converted to SQL.

So: is there an equals operator that I can use in an expression block, or 
is the long timestamp query I wrote the only way to do this?

Thanks!
Andrew

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to