# Path: tests/fake_model.py
# def get_fake_model(fields=None, model_base=PostgresModel, meta_options={}):
#     """Defines a fake model and creates it in the database."""
# 
#     model = define_fake_model(fields, model_base, meta_options)
# 
#     with connection.schema_editor() as schema_editor:
#         schema_editor.create_model(model)
# 
#     return model


from django.db import models
from .fake_model import get_fake_model
        )
    )
    assert results == [a, b]


def test_invalues_lookup_related_field():
    model_1 = get_fake_model({"name": models.TextField()})
    model_2 = get_fake_model(
        {"relation": models.ForeignKey(model_1, on_delete=models.CASCADE)}
    )

    [a_relation, b_relation] = model_1.objects.bulk_create(
        [
            model_1(name="a"),
            model_1(name="b"),
        ]
    )

    [a, b] = model_2.objects.bulk_create(
        [model_2(relation=a_relation), model_2(relation=b_relation)]
    )

    results = list(
        model_2.objects.filter(relation__invalues=[a_relation, b_relation])
    )
    assert results == [a, b]


def test_invalues_lookup_related_field_subquery():
    model_1 = get_fake_model({"name": models.TextField()})

# Path: tests/fake_model.py
# def get_fake_model(fields=None, model_base=PostgresModel, meta_options={}):
#     """Defines a fake model and creates it in the database."""
# 
#     model = define_fake_model(fields, model_base, meta_options)
# 
#     with connection.schema_editor() as schema_editor:
#         schema_editor.create_model(model)
# 
#     return model


# Path: tests/test_lookups.py
from django.db import models
from .fake_model import get_fake_model

        )
    )
    assert results == [a, b]


def test_invalues_lookup_related_field():
    model_1 = get_fake_model({"name": models.TextField()})
    model_2 = get_fake_model(
        {"relation": models.ForeignKey(model_1, on_delete=models.CASCADE)}
    )

    [a_relation, b_relation] = model_1.objects.bulk_create(
        [
            model_1(name="a"),
            model_1(name="b"),
        ]
    )

    [a, b] = model_2.objects.bulk_create(
        [model_2(relation=a_relation), model_2(relation=b_relation)]
    )

    results = list(
        model_2.objects.filter(relation__invalues=[a_relation, b_relation])
    )
    assert results == [a, b]


def test_invalues_lookup_related_field_subquery():
    model_1 = get_fake_model({"name": models.TextField()})

    model_2 = get_fake_model(