Skip to content Skip to sidebar Skip to footer

Sqlite3 Activerecord :order => "time Desc" Doesn't Sort

rails 2.3.4, sqlite3 I'm trying this Production.find(:all, :conditions => ['time > ?', start_time.utc], :order => 'time DESC', :limit => 100) The condition works perf

Solution 1:

It is usually a bad idea to use reserved words without surrounding quotes. time is a built-in function in SQLite, try using the following instead and better get rid of the ambiguity in the first place:

Production.find(:all,
                :conditions => ["`time` > ?", start_time.utc],
                :order => "`time` DESC",
                :limit => 100)

UPD: The problem seems to have appeared on SO:

Rails Active Record find(:all, :order => ) issue

Post a Comment for "Sqlite3 Activerecord :order => "time Desc" Doesn't Sort"