Mysql2 :: Error:您的SQL语法有错误 [英] Mysql2::Error: You have an error in your SQL syntax
本文介绍了Mysql2 :: Error:您的SQL语法有错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是使用 this 来将我的Rails应用程序数据库从sqlite3切换到mysql2,这似乎可以正常工作.
I just used this to switch my rails app db from sqlite3 to mysql2 and that seemed to work out properly.
但是,当我启动我的应用程序时,我现在得到这个:
But when I start up my app I'm now getting this:
A ActionView::Template::Error occurred in pages#dashboard:
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '== 1) LIMIT 20 OFFSET 0' at line 1: SELECT `tickets`.* FROM `tickets` WHERE (archived == 1) LIMIT 20 OFFSET 0
activerecord (3.0.3) lib/active_record/connection_adapters/abstract_adapter.rb:202:in `log'
不确定如何定位才能正常工作.任何帮助,将不胜感激.谢谢!
Not sure where to look to get this working properly. Any help would be appreciated. Thanks!
推荐答案
尝试一下:
# Notice single = vs ==
WHERE (archived = 1)
更新 最终做了
Update Ended up doing
scope :is_archived, where('archived != ?', 1)
scope :not_archived, where('archived = ?', 1)
效果很好.谢谢!
这篇关于Mysql2 :: Error:您的SQL语法有错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文