ernie/squeel — Issue #85: Time.now from param in a resque job
Author: NielsKSchjoedt
Created: 2011-12-08 22:40:19+00:00
State: open

Hi I don't know if this is a bug, or if it's something that I should know of and handle myself. I'm running 3.1 and I'm in config.time_zone = 'Copenhagen'

I have a job in resque that looks like this, when it's beeing queued:

```ruby
Resque.enqueue(Lookups::Workers::CleaningJob, site, Time.now - 5.minutes)
´´´

Now, this stores a job like this in resque:

Crawling::Workers::AdvertCleaningJob	["Google", "2011-12-08T22:30:52+01:00"]

Now the problem shows, when I later run the queued job. The job executes a query, that uses the timestamp (in a variable called last_cleaned_time = "2011-12-08T22:30:52+01:00")

```ruby
Site.where{(site == site_name) & (last_cleaned < last_cleaned_time)}
´´´
This executes a query looking something like this:

```sql
SELECT "sites".* FROM "sites" WHERE (("sites"."site" = 'Google' AND "sites"."last_cleaned" = '2011-12-08T22:30:52+01:00'))
```

And THAT is not what I want - the time has not been parsed correctly.

If I for testing do like this in the console:

```ruby
site.update_attribute(:last_cleaned, "2011-12-08T22:30:52+01:00")
´´´

I can see from the resulting sql, that it translates the time correctly

```sql
UPDATE "sites" SET "last_cleaned" = '2011-12-08 21:30:52.000000', "updated_at" = '2011-12-08 22:14:30.632682' WHERE "sites"."id" = 12
```

So in other words - I would have expected sqeel to handle this, just like rails, without doing a Time.parse() on the variable?