Repository: stphivos/django-mock-queries (language: python)

Issue:
Contains comparison doesn't work as expected for PostgreSQL ArrayField
Defining a model with ArrayField supports contains filtering but should work differently from the string contains comparison. The comparison should support both fields
```python
def test_mock_set_contains():
    from django.contrib.postgres.fields import ArrayField
    from django.db.models import IntegerField, Model
    from django_mock_queries.query import MockSet

    class TestModel(Model):
        x = ArrayField(IntegerField())

        class Meta:
            app_label = "prompt"

    set = MockSet(model=TestModel)
    assert len(set.filter(x__contains=[1])) == 0
    set.create(x=[1, 2, 3])
    assert len(set.filter(x__contains=[1])) == 1
```


Discussion / hints:

Fix patch:
diff --git a/django_mock_queries/comparisons.py b/django_mock_queries/comparisons.py
index dbccfc3..852bbfd 100644
--- a/django_mock_queries/comparisons.py
+++ b/django_mock_queries/comparisons.py
@@ -10,6 +10,9 @@ def iexact_comparison(first, second):
 
 
 def contains_comparison(first, second):
+    if isinstance(first, (list, tuple)):
+        return set(second).issubset(first)
+
     return second in first
 
 


Test patch:
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 4d9483d..ccadf56 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -116,6 +116,19 @@ def test_is_match_case_sensitive_contains_check(self):
         result = utils.is_match('abc', 'a', constants.COMPARISON_CONTAINS)
         assert result is True
 
+    def test_is_match_case_list_contains_check(self):
+        result = utils.is_match([1, 2, 3], [1, 2], constants.COMPARISON_CONTAINS)
+        assert result is True
+
+        result = utils.is_match([1, 2, 3], [1, 4], constants.COMPARISON_CONTAINS)
+        assert result is False
+
+        result = utils.is_match((1, 2, 3), (1, 2), constants.COMPARISON_CONTAINS)
+        assert result is True
+
+        result = utils.is_match((1, 2, 3), (1, 2, 3, 4), constants.COMPARISON_CONTAINS)
+        assert result is False
+
     def test_is_match_case_insensitive_contains_check(self):
         result = utils.is_match('abc', 'A', constants.COMPARISON_ICONTAINS)
         assert result is True