diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-10-29 01:28:40 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-11-14 10:07:43 +0900 |
commit | 8be9c710f612cac7f2121b8f829ecbdc05d8d385 (patch) | |
tree | f5da377fd52ccf3e56c4b3aeaee765c2380915ab /activerecord | |
parent | 087921af292dbbfcaab4dc716f0f449a9f251957 (diff) | |
download | rails-8be9c710f612cac7f2121b8f829ecbdc05d8d385.tar.gz rails-8be9c710f612cac7f2121b8f829ecbdc05d8d385.tar.bz2 rails-8be9c710f612cac7f2121b8f829ecbdc05d8d385.zip |
Fix NameError: undefined local variable or method `result`
Caused by 007e50d8e5a900547471b6c4ec79d9d217682c5d.
https://github.com/rails/rails/pull/26925 was closed in favor of dcb364e.
But dcb364e is only fixed sqlite3 adapter and still broken mysql2
adapter with `prepared_statements: true` (`exec_stmt_and_free`).
```diff
diff --git a/activerecord/test/config.example.yml b/activerecord/test/config.example.yml
index 58e2d45..7b3c1a6 100644
--- a/activerecord/test/config.example.yml
+++ b/activerecord/test/config.example.yml
@@ -56,9 +56,11 @@ connections:
username: rails
encoding: utf8
collation: utf8_unicode_ci
+ prepared_statements: true
arunit2:
username: rails
encoding: utf8
+ prepared_statements: true
oracle:
arunit:
```
```
% be rake test_mysql2 --verbose
...
Using mysql2
/Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb:90: warning: assigned but unused variable - result
/Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb:101:in `block in exec_stmt_and_free': NameError: undefined local variable or method `result' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007fe2c50eb140>: SELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = ? LIMIT ? (ActiveRecord::StatementInvalid)
from /Users/kamipo/src/github.com/rails/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:586:in `block in log'
...
```
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb index 274753a8a5..c7098105a8 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql/database_statements.rb @@ -86,8 +86,8 @@ module ActiveRecord end begin - ActiveSupport::Dependencies.interlock.permit_concurrent_loads do - result = stmt.execute(*type_casted_binds) + result = ActiveSupport::Dependencies.interlock.permit_concurrent_loads do + stmt.execute(*type_casted_binds) end rescue Mysql2::Error => e if cache_stmt |