active_fedora icon indicating copy to clipboard operation
active_fedora copied to clipboard

QueryMethods #limit does not limit correctly

Open dchandekstark opened this issue 11 years ago • 3 comments

It seems that the incorrectness is related to the number of objects of that type -- greater factor of error as the number of objects increases.

2.1.2 :012 > Component.limit(5).size
 => 60 
2.1.2 :013 > Item.limit(5).size
 => 35 
2.1.2 :014 > Collection.limit(5).size
 => 5 
2.1.2 :015 > Target.limit(5).size
 => 5 
2.1.2 :016 > Attachment.limit(5).size
 => 5 

dchandekstark avatar Aug 26 '14 20:08 dchandekstark

I think this problem may be caused by find_in_batches applying :rows to each batch instead of the entire result. See #468

dchandekstark avatar Aug 26 '14 20:08 dchandekstark

Do you get a different result using count instead of size?

jcoyne avatar Aug 26 '14 21:08 jcoyne

Yes, with count, limit has no effect:

2.1.2 :001 > Component.limit(5).count
 => 11472 
2.1.2 :005 > Component.count
 => 11472 

dchandekstark avatar Aug 27 '14 00:08 dchandekstark