Sorry for this noob question but I can't get it work after few hours
on it, it's getting me crazy...
the long story is:
I have a model with subset methods that use a dynamic argument based
on Time.now
subset(:recent) { |p| (!p.published) | (p.published < Time.now - 3600
* 24) }
First thing I spotted: I need to use this syntax in order that
Time.now is called each time I call MyModel.
this line:
subset(:tt, :published < Time.now - 3600 * 24)
doesn't work, Time.now is called once when loading my model and keep
this value each call to the subset.
But what I totally don't understand, it's how OR / AND and NULL values
is used
I tried:
>> News.filter { (!published ) | (published < Time.now - 3600 * 24}
=> #<Sequel::Postgres::Dataset: "SELECT * FROM \"news\" WHERE true">
>> News.filter { (~published ) | (published < Time.now - 3600 * 24}
=> #<Sequel::Postgres::Dataset: "SELECT * FROM \"news\" WHERE (NOT
\"published \" OR (\"published \" < '2009-10-09
18:56:29.704914+0200'))">
>> News.filter { (published = nil) | (published < Time.now - 3600 * 24}
NoMethodError: undefined method `<' for nil:NilClass
>> News.filter { |o| (o.published = nil.sql_expr) | (o.published < Time.now -
>> 3600 * 24) }
NoMethodError: undefined method `sql_expr' for nil:NilClass
I just want to filter all NULL values OR rows for 1 day.
I tried to combine filter with exclude but I don't want a NOT I would
like a IS NULL
Any help is appreciated :)
Best regards,
Florent
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---