Created
July 12, 2010 16:47
-
-
Save noahhendrix/472702 to your computer and use it in GitHub Desktop.
Sample code to demonstrate ideal behavior in MetaSearch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = Activity.search | |
# => #<MetaSearch::Builder:0x000001053b4588 @relation=[#<Activity id: 1... | |
s.date_gteq = Date.yesterday | |
# => Sun, 11 Jul 2010 | |
s.to_sql | |
# => "SELECT \"activities\".* FROM \"activities\" WHERE (\"activities\".\"date\" >= '2010-07-11')" | |
s.date_gteq = s.date_gteq.beginning_of_week | |
# => Mon, 05 Jul 2010 | |
s.to_sql | |
# => "SELECT \"activities\".* FROM \"activities\" WHERE (\"activities\".\"date\" >= '2010-07-11') AND (\"activities\".\"date\" >= '2010-07-05')" | |
#In the last SQL statement it obviously doesn't work as I expect because it appends the date clause twice, and the latest one is the only one that takes affect. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment