orslumen/record-cache — Issue #21: Rails 3.2.2 Insert problem
Author: zonecheung
Created: 2012-03-05 11:12:35+00:00
State: open

Right after I upgraded to Rails 3.2.2, a bunch of my insert queries ran into this issue:

```ruby
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 '?, ?, ?, ?, ?, ?)' at line 1: INSERT INTO `hits` (`count`, `hittable_id`, `hittable_type`, `last_ip`, `last_session_id`, `updated_at`) VALUES (?, ?, ?, ?, ?, ?)

activerecord (3.2.2) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `query'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `block in execute'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log'
activesupport (3.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:243:in `execute'
activerecord (3.2.2) lib/active_record/connection_adapters/mysql2_adapter.rb:211:in `execute'
activerecord (3.2.2) lib/active_record/connection_adapters/mysql2_adapter.rb:234:in `exec_insert'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:90:in `insert'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
activerecord (3.2.2) lib/active_record/relation.rb:66:in `insert'
activerecord (3.2.2) lib/active_record/persistence.rb:363:in `create'
activerecord (3.2.2) lib/active_record/timestamp.rb:57:in `create'
activerecord (3.2.2) lib/active_record/callbacks.rb:268:in `block in create'
activesupport (3.2.2) lib/active_support/callbacks.rb:403:in `_run__1739378914581683821__create__1567641559477807594__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.2) lib/active_record/callbacks.rb:268:in `create'
activerecord (3.2.2) lib/active_record/persistence.rb:344:in `create_or_update'
activerecord (3.2.2) lib/active_record/callbacks.rb:264:in `block in create_or_update'
activesupport (3.2.2) lib/active_support/callbacks.rb:403:in `_run__1739378914581683821__save__1567641559477807594__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.2) lib/active_record/callbacks.rb:264:in `create_or_update'
activerecord (3.2.2) lib/active_record/persistence.rb:84:in `save'
activerecord (3.2.2) lib/active_record/validations.rb:50:in `save'
activerecord (3.2.2) lib/active_record/attribute_methods/dirty.rb:22:in `save'
activerecord (3.2.2) lib/active_record/transactions.rb:241:in `block (2 levels) in save'
activerecord (3.2.2) lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
activerecord (3.2.2) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.2.2) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.2.2) lib/active_record/transactions.rb:241:in `block in save'
activerecord (3.2.2) lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
activerecord (3.2.2) lib/active_record/transactions.rb:240:in `save'
app/models/hit.rb:15:in `create_hit'
```

It worked fine when I removed the record-cache gem from the system. Somehow, the sql string isn't translated correctly and passed into activerecord. I'm not sure where to look to fix this one.