Sqlite3 activerecord :order => “time DESC” doesn't sort

前端 未结 1 1973
悲哀的现实
悲哀的现实 2021-01-14 03:05

rails 2.3.4, sqlite3

I\'m trying this

Production.find(:all, :conditions => ["time > ?", start_time.utc], :order => "time D

相关标签:
1条回答
  • 2021-01-14 03:51

    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

    0 讨论(0)
提交回复
热议问题