Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NoMethodError: undefined method fields' for nil:NilClass` #23954

Merged
merged 1 commit into from Mar 1, 2016

Conversation

kamipo
Copy link
Member

@kamipo kamipo commented Feb 29, 2016

Currently exec_query raises NoMethodError when executing no result
queries (INSERT, UPDATE, DELETE, and all DDL) in mysql2 adapter.

irb(main):002:0> conn.execute("create table t(a int)")
   (43.3ms)  create table t(a int)
=> nil
irb(main):003:0> conn.execute("insert into t values (1)")
   (19.3ms)  insert into t values (1)
=> nil
irb(main):004:0> conn.exec_query("insert into t values (1)")
  SQL (28.6ms)  insert into t values (1)
NoMethodError: undefined method `fields' for nil:NilClass

Currently `exec_query` raises `NoMethodError` when executing no result
queries (`INSERT`, `UPDATE`, `DELETE`, and all DDL) in mysql2 adapter.

```
irb(main):002:0> conn.execute("create table t(a int)")
   (43.3ms)  create table t(a int)
=> nil
irb(main):003:0> conn.execute("insert into t values (1)")
   (19.3ms)  insert into t values (1)
=> nil
irb(main):004:0> conn.exec_query("insert into t values (1)")
  SQL (28.6ms)  insert into t values (1)
NoMethodError: undefined method `fields' for nil:NilClass
```
@rails-bot
Copy link

r? @matthewd

(@rails-bot has picked a reviewer for you, use r? to override)

rafaelfranca added a commit that referenced this pull request Mar 1, 2016
Fix `NoMethodError: undefined method `fields' for nil:NilClass`
@rafaelfranca rafaelfranca merged commit 159c73a into rails:master Mar 1, 2016
@kamipo kamipo deleted the fix_undefined_method_fields branch March 1, 2016 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants