rails/rails — Issue #4754: MySQL running on ANSI QUOTES fails insert (Regression 3.1.3 -> 3.2.1)
Author: seantan
Created: 2012-01-30 09:34:08+00:00
State: open

Tested this on a fresh Rails 3.2.1 installation

When connecting to a MySQL 5.5 server running on ANSI_QUOTES mode, specifically having this in my.cnf

sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES"

ActiveRecord is unable to insert any new records.

Running this on Rails 3.1.3 console
```
AppConfig.create!(ckey: 'a', cvalue: 'b')

(0.2ms) BEGIN
SQL (0.4ms) INSERT INTO `app_configs` (`ckey`, `cvalue`) VALUES ('a', 'b')
(0.7ms) COMMIT
=> #
```

Running this on Rails 3.2.1 console
```ruby
AppConfig.create!(ckey: 'a', cvalue: 'b')
(0.3ms) BEGIN
SQL (0.5ms) INSERT INTO `app_configs` (`ckey`, `cvalue`, `id`) VALUES ('a', 'b', NULL)
(0.7ms) ROLLBACK
ActiveModel::MissingAttributeError: can't write unknown attribute `"id"'
```

When I removed ANSI_QUOTES from the my.cnf, the Rails 3.2.1 console produces the same output as 3.1.3, thus successful in row insertion.