active_fedora
active_fedora copied to clipboard
QueryMethods #limit does not limit correctly
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
I think this problem may be caused by find_in_batches applying :rows to each batch instead of the entire result. See #468
Do you get a different result using count instead of size?
Yes, with count, limit has no effect:
2.1.2 :001 > Component.limit(5).count
=> 11472
2.1.2 :005 > Component.count
=> 11472