Skip to content

Deprecate Class handler in PredicateBuilder#17916

Merged
sgrif merged 1 commit into
rails:masterfrom
mrgilman:deprecate-class-handler
Dec 4, 2014
Merged

Deprecate Class handler in PredicateBuilder#17916
sgrif merged 1 commit into
rails:masterfrom
mrgilman:deprecate-class-handler

Conversation

@mrgilman
Copy link
Copy Markdown

@mrgilman mrgilman commented Dec 4, 2014

Users should pass strings to queries instead of classes

@rafaelfranca
Copy link
Copy Markdown
Member

Could you add a CHANGELOG entry?

@mrgilman
Copy link
Copy Markdown
Author

mrgilman commented Dec 4, 2014

Sure thing.

Users should pass strings to queries instead of classes
@mrgilman mrgilman force-pushed the deprecate-class-handler branch from 0c1e0dd to c0609dd Compare December 4, 2014 20:06
@mrgilman
Copy link
Copy Markdown
Author

mrgilman commented Dec 4, 2014

Added a CHANGELOG entry.

sgrif added a commit that referenced this pull request Dec 4, 2014
Deprecate `Class` handler in `PredicateBuilder`
@sgrif sgrif merged commit 6c9ed6d into rails:master Dec 4, 2014
@joergschray
Copy link
Copy Markdown
Contributor

Passing a class for the type column of a polymorphic relationship or an STI table makes perfect sense to me. Of course you can work around it by defining a visitor in Arel, but that's not readily accessible for most users. So I think the use case in the test should be fixed, but not the concept as such.

@sgrif
Copy link
Copy Markdown
Contributor

sgrif commented Dec 8, 2014

Why is passing Foo so much better than calling "Foo"? You can also call .name on the class if you need to take one as an argument. It simply adds cruft to our code for a type that has no semantics on its own.

@joergschray
Copy link
Copy Markdown
Contributor

For a namespaced class Foo is not equivalent to "Foo". Yes I can also call .name - but why is passing a symbol or an ActiveRecord instance allowed - I could also call .to_s or .id on it. What is the criteria to approve of one and disapprove of the other?

@rafaelfranca
Copy link
Copy Markdown
Member

What is the criteria to approve of one and disapprove of the other?

I'd say usage. Symbol and Active Record instance are more used.

pikender pushed a commit to vinsol-spree-contrib/spree_marketing that referenced this pull request Feb 3, 2017
Fixed Deprecation Warning :: Passing a class as a value in an Active Record query is deprecated and will be removed. Pass a string instead.
Refer rails/rails#17916
Used Rspec stub_const to silence CONSTANT redefinition warnings
Pending: Failing Specs for acts_as_multilist concern
TRACE_START
Spree::Marketing::List::MostZoneWiseOrders behaves like acts_as_multilist .generator if list doesn't exists should change result by 1
      Failure/Error: it { expect { list_type.send :generator }.to change { list_type.all.count }.by 1 }
        expected result to have changed by 1, but was changed by 0
      Shared Example Group: "acts_as_multilist" called from ./spec/models/spree/marketing/list/most_zone_wise_orders_list_spec.rb:12
      # ./spec/shared/acts_as_multilist.rb:59:in `block (4 levels) in <top (required)>'
TRACE_END
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.

4 participants