Note that there are some explanatory texts on larger screens.

plurals
  1. PORails, Heroku and PG Syntax Error for queries with conditions
    text
    copied!<p>I have been trying to make simple queries with two conditions with <code>start</code> and <code>end</code> datetimes.</p> <p>In development mode I don't have any problem and it seems to work well (SQLite)</p> <p>In production mode however I have the following error:</p> <pre><code> ActionView::Template::Error (PG::Error: ERROR: syntax error at or near "end" LINE 1: ...ions" WHERE (start &gt;= '2013-01-30T10:12:24Z' AND end &gt;= '20... : SELECT COUNT(*) FROM "missions" WHERE (start &gt;= '2013-01-30T10:12:24Z' AND end &gt;= '2013-01-30T10:12:24Z')): ^ 6: &lt;li class="mission clearfix"&gt; 1: &lt;h4 class="heading-sep"&gt;&lt;%= t(".upcoming_missions")%&gt;&lt;/h4&gt; 2: &lt;div class="missions-timeline"&gt; 3: &lt;ul class="mission-list"&gt; app/views/users/show.html.erb:12:in `_app_views_users_show_html_erb___1717297229253226868_63256380' 7: &lt;div class="mission-wrap clearfix"&gt; 4: &lt;% if @upcoming_missions.any? %&gt; 5: &lt;% @upcoming_missions.each do |mission| %&gt; app/views/users/_mission_timeline.html.erb:4:in `_app_views_users__mission_timeline_html_erb__2786253018340202740_62779040' </code></pre> <p>In my controller I have the following queries:</p> <pre><code>@upcoming_missions = Mission.where("start &gt;= ? AND end &gt;= ?", Time.now, Time.now).order("created_at DESC") @current_missions = Mission.where("start &lt;= ? AND end &gt;= ?", Time.now, Time.now).order("created_at DESC") @past_missions = Mission.where("start &lt;= ? AND end &lt;= ?", Time.now, Time.now).order("created_at DESC") </code></pre> <p>I tried other suggestions by including <code>.utc</code> in case PG reads time differently than SQLite... but I am not sure where the problem is. </p> <p>Thank you for your help</p> <p>Aurelien</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload