Concatenate the Mongomapper region

I experience strange behavior with concatenation of the mongomapper area.

Below is an example.

I have two areas:

scope :active, where( :name => { :$in => Model2.active.distinct(:city) } ) scope :by_htype_id, lambda{|htype_id| where( :name => { :$in => Model2.by_htype_id(htype_id).distinct(:city) } ) } 

If I run

Model1.by_htype_id("some_id") works as expected

but if I combine the two regions Model1.active.by_htype_id("some_id") , I get the whole result from the active region, while I expect to get a subset of the active region, which depends on by_htype_id

EDIT: If I write the concatenation of a region as a single query, it will work as expected. I expect concatenation to unite the two areas. As I said, I have a problem with some areas, not with every area.

+5
source share

Source: https://habr.com/ru/post/1268819/


All Articles