On Thursday, June 13, 2019 at 10:23:00 AM UTC-7, Tom wrote:
>
> Following up the issue I posted here 
> <https://github.com/jeremyevans/sequel/issues/1624> (Sorry if I should 
> have directed it here first)
>
> I'm wondering why the behavior is to return the receiver instead of the 
> subclass? Could you override the create for STI models like so? Are there 
> any negative side effects to this method? Maybe make it optional on a per 
> class basis?
>
>
> def self.create(**args)
>   (self.sti_model_map[args[self.sti_key]] || self.to_s.to_sym).to_s.
> constantize.create(args)
> end
>

Other than the fact that this causes a SystemStackError due to unbounded 
recursion, it should be fine. You can definitely fix the recursion issue.  
That being said, I don't plan to change the default behavior of create.  
Doing so could definitely break backwards compatibility. Potentially, the 
behavior you want could be supported via a plugin option.  If you are 
interested in adding it, please submit a pull request with the appropriate 
documentation and specs.  Note that you would probably want to override 
new, not create, because create calls new and you wouldn't want the two 
methods to have different behavior.

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/19eb12a8-30e4-41cd-88ef-f578f174aafa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to