-
Ryuta Kamizono authored
Regardless of whether doing implicit `create_with` or not, `sti_name` is set by `ensure_proper_type`. https://github.com/rails/rails/blob/11f54e12b992f6c8d29fd9bedd89ac438a928a2f/activerecord/lib/active_record/inheritance.rb#L289-L304 The purpose of the `create_with` is to suppress/override `type_condition`, since `type_condition` will be an array of all sti subclass names for `scope_for_create`, it is not desired behavior for `scope_for_create`, and it will cause `find_sti_class` to fail. That undesired behavior was derived from `In` arel node was accidentally a subclass of `Equality` node, IMHO it is considered as almost a bug. But someone depends on the behavior for now (see also #39288). Unfortunately that implicit `create_with` had an unwanted side effect to fail `or` with STI subclass relation #39956. This changes a way to suppress/override `type_condition`, from doing implicit `create_with` to excepting `type_condition` in `scope_for_create`, to fix the `or` issue #39956.
Ryuta Kamizono authoredRegardless of whether doing implicit `create_with` or not, `sti_name` is set by `ensure_proper_type`. https://github.com/rails/rails/blob/11f54e12b992f6c8d29fd9bedd89ac438a928a2f/activerecord/lib/active_record/inheritance.rb#L289-L304 The purpose of the `create_with` is to suppress/override `type_condition`, since `type_condition` will be an array of all sti subclass names for `scope_for_create`, it is not desired behavior for `scope_for_create`, and it will cause `find_sti_class` to fail. That undesired behavior was derived from `In` arel node was accidentally a subclass of `Equality` node, IMHO it is considered as almost a bug. But someone depends on the behavior for now (see also #39288). Unfortunately that implicit `create_with` had an unwanted side effect to fail `or` with STI subclass relation #39956. This changes a way to suppress/override `type_condition`, from doing implicit `create_with` to excepting `type_condition` in `scope_for_create`, to fix the `or` issue #39956.
Loading