Marc
Marc

Reputation: 2584

Mysql2::Error: You have an error in your SQL syntax

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!

Upvotes: 1

Views: 4582

Answers (1)

Mike Purcell
Mike Purcell

Reputation: 19999

Try this:

# Notice single = vs ==
WHERE (archived = 1)

Update Ended up doing

scope :is_archived, where('archived != ?', 1)
scope :not_archived, where('archived = ?', 1)

This worked great. Thanks!

Upvotes: 4

Related Questions