STI find should filter on type
thhermansen opened this issue · comments
If we have a class Person
and a subclass Friend
and we have only one person-record in our database and we do a Friend.first
or Friend.all
we'll get back that person object (as MassiveRecord currently only scans the table and return records instantiated with correct type).
It is really not that efficient, but I think we should make sure to reject Person
objects when doing a Friend.first
. It should return nil if only objects of class Person
exists.
This was not fixed after all. Having multiple classes in a table and doing SubClass.first might get you into trouble. Will look into it when I have time, but you might end up with getting nil back.