Describe the bug
You cannot declare scopes with the same name in different models. If you do that, the last declared one overwrites the previous ones.
To Reproduce
class Cat(Model):
# suppose Cats table has only the 'cat_color' column
@scope
def filter_color(self, query, op='=', value=''):
return query.where('cat_color', op, value)
class Dog(Model):
# suppose Dogs table has only the 'dog_color' column
@scope
def filter_color(self, query, op='=', value=''):
return query.where('dog_color', op, value)
cat = Cat.filter_color("=", "white").first() # the wrong scope is called (from the Dog class)
Expected behavior
Scopes should be retrieved from the correct class in which they are declared.
Describe the bug You cannot declare scopes with the same name in different models. If you do that, the last declared one overwrites the previous ones.
To Reproduce
Expected behavior Scopes should be retrieved from the correct class in which they are declared.
What database are you using?