Skip to content

ActiveRecord MySQL bug? #120

@agbodike

Description

@agbodike

I'm getting a SQL error in MySQL:

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 'key FROM `flipper_features`' at line 1: SELECT key FROM `flipper_features`

I believe it's due to not putting backticks around key, which is a reserved word in mysql.

The issue does not happen in postgres

We are on an older version of rails (4.0)

Log output:

Started GET "/flipper" for 127.0.0.1 at 2016-05-05 16:46:07 -0700


Started GET "/flipper/features" for 127.0.0.1 at 2016-05-05 16:46:07 -0700
  Flipper::Adapters::ActiveRecord::Feature Load (0.5ms)  SELECT key FROM `flipper_features`
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 'key FROM `flipper_features`' at line 1: SELECT key FROM `flipper_features`

ActiveRecord::StatementInvalid (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 'key FROM `flipper_features`' at line 1: SELECT key FROM `flipper_features`):
  app/middleware/decompress_request.rb:16:in `call'


  Rendered .rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.7ms)
  Rendered .rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.0ms)
  Rendered .rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.5ms)
  Rendered .rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.0.13/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (67.0ms)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions