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

Removed where_values_hash from AR::NullRelation #11496

Conversation

@pftg
Copy link
Contributor

pftg commented Jul 18, 2013

In order to build associated records for owners which has not been saved
need to get where values to use as default attributes.
But for new record owner uses ActiveRecord::NullRelation which
override where_values_hash to return empty hash stub.

where_values_hash is not used to invoke any sql query, but good to
build others chains (even will be never executed) like:

  post          = Post.new
  admin_comment = post.admin_comments.build

  assert_equal 'Admin', admin_comment.author

Closes #11376, #11676 and #11675

@pftg
Copy link
Contributor Author

pftg commented Jul 18, 2013

@nathanvda
Copy link

nathanvda commented Aug 8, 2013

👍 Nice work, thank you!

@pftg
Copy link
Contributor Author

pftg commented Aug 13, 2013

Thanks to @beerlington and @Nthalk for their tests and CHANGELOG

@pftg
Copy link
Contributor Author

pftg commented Aug 13, 2013

@rafaelfranca may you check this one, thanks in advance.

@jarl-dk
Copy link

jarl-dk commented Sep 20, 2013

Could someone please merge this, it seems to resolve more than one bug report.

@Maxim-Filimonov
Copy link

Maxim-Filimonov commented Sep 24, 2013

Run into the same issue today with Rails 4. Is it gonna be merged for 4.1.0 ?

@leiyangyou
Copy link

leiyangyou commented Sep 25, 2013

+1

In order to build associated records for owners which has not been saved
need to get where values to use as default attributes.
But for new record owner uses `ActiveRecord::NullRelation` which
override `where_values_hash` to return empty hash stub.

`where_values_hash` is not used to invoke any sql query, but good to
build others chains (even will be never executed) like:

```ruby
  post          = Post.new
  admin_comment = post.admin_comments.build

  assert_equal 'Admin', admin_comment.author
```

Closes #11376, #11676, #11675
@pftg
Copy link
Contributor Author

pftg commented Sep 28, 2013

Rebased!

rafaelfranca added a commit that referenced this pull request Sep 29, 2013
…ct_scope_on_build

Removed where_values_hash from AR::NullRelation
@rafaelfranca rafaelfranca merged commit 8771a56 into rails:master Sep 29, 2013
1 check passed
1 check passed
default The Travis CI build passed
Details
@rafaelfranca
Copy link
Member

rafaelfranca commented Sep 29, 2013

Merged. Sorry for the delay guys

rafaelfranca added a commit that referenced this pull request Sep 29, 2013
…ct_scope_on_build

Removed where_values_hash from AR::NullRelation
Conflicts:
	activerecord/CHANGELOG.md
@pftg pftg deleted the jetthoughts:11376_has_many_assoc_respect_scope_on_build branch Sep 29, 2013
@jarl-dk
Copy link

jarl-dk commented Sep 29, 2013

Thanks... Any plans for a 4.0.1 release?

@nathanvda
Copy link

nathanvda commented Sep 29, 2013

Thanks @rafaelfranca! 👍

@robin850
Copy link
Member

robin850 commented Sep 30, 2013

@jarl-dk : Yes, the pull request has been backported to the 4-0-stable branch so it will be in 4.0.1 which will be released soon. There is still issues which need to be resolved to get 4.0.1 out unfortunately.

@jarl-dk
Copy link

jarl-dk commented Oct 1, 2013

@robin850: I hope this bug (#12417) is one of those that need to be resolved in 4-0-stable.

@robin850
Copy link
Member

robin850 commented Oct 1, 2013

@jarl-dk : Most of the time, the issues are put under a "milestone" on this tracker. As you can see, this is under the 4.0.1 milestone so this should be. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

7 participants
You can’t perform that action at this time.