当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby on rails - Postgres syntax (Sqlite3 syntax that doesnt work in postgres)

问题描述:

I'm having trouble with postgres syntax.

My code is as follows:

output = Course.select("DISTINCT courses.*").where(:semester => Semester.current_semester(input[:semester])).where(:pending => pending)

output = Section.need_to_filter(input) ? output.joins(:sections) : output.joins("LEFT JOIN sections")

output = output.where(:category => input[:category]) if input[:category]

output = output.where('title ILIKE ?', "%#{input[:search_field]}%") if !input[:search_field].blank?

And here's the error image

It has something to do with the join, because that's where it stops, but since I have sqlite3 in development I'm not sure how to test it efficiently.

Can anyone help?

网友答案:

You miss ON statement in joins

...
output = Section.need_to_filter(input) ? output.joins(:sections) : output.joins("LEFT JOIN sections ON sections.course_id = courses.id")
...
分享给朋友:
您可能感兴趣的文章:
随机阅读: