# Path: psqlextra/query.py
# class PostgresQuerySet(models.QuerySet):
#     def __init__(self, model=None, query=None, using=None, hints=None):
#     def annotate(self, **annotations):
#     def rename_annotations(self, **annotations):
#     def on_conflict(
#         self,
#         fields: ConflictTarget,
#         action: ConflictAction,
#         index_predicate: Optional[Union[Expression, Q, str]] = None,
#         update_condition: Optional[Union[Expression, Q, str]] = None,
#     ):
#     def bulk_insert(
#         self,
#         rows: List[dict],
#         return_model: bool = False,
#         using: Optional[str] = None,
#     ):
#     def insert(self, using: Optional[str] = None, **fields):
#     def insert_and_get(self, using: Optional[str] = None, **fields):
#     def upsert(
#         self,
#         conflict_target: ConflictTarget,
#         fields: dict,
#         index_predicate: Optional[Union[Expression, Q, str]] = None,
#         using: Optional[str] = None,
#         update_condition: Optional[Union[Expression, Q, str]] = None,
#     ) -> int:
#     def upsert_and_get(
#         self,
#         conflict_target: ConflictTarget,
#         fields: dict,
#         index_predicate: Optional[Union[Expression, Q, str]] = None,
#         using: Optional[str] = None,
#         update_condition: Optional[Union[Expression, Q, str]] = None,
#     ):
#     def bulk_upsert(
#         self,
#         conflict_target: ConflictTarget,
#         rows: Iterable[Dict],
#         index_predicate: Optional[Union[Expression, Q, str]] = None,
#         return_model: bool = False,
#         using: Optional[str] = None,
#         update_condition: Optional[Union[Expression, Q, str]] = None,
#     ):
#         def is_empty(r):
#     def _create_model_instance(
#         self, field_values: dict, using: str, apply_converters: bool = True
#     ):
#     def _build_insert_compiler(
#         self, rows: Iterable[Dict], using: Optional[str] = None
#     ):
#     def _is_magical_field(self, model_instance, field, is_insert: bool):
#     def _get_upsert_fields(self, kwargs):
# 
# 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 psqlextra.query import ConflictAction
from .fake_model import get_fake_model

    obj1 = model.objects.get()
    assert obj1.pk == pk
    assert obj1.cookies == "some-cookies"


def test_insert_explicit_pk():
    """Tests whether inserts works when the primary key is explicitly
    specified."""

    model = get_fake_model(
        {
            "name": models.CharField(max_length=255, primary_key=True),
            "cookies": models.CharField(max_length=255, null=True),
        }
    )

    pk = model.objects.all().insert(name="the-object", cookies="some-cookies")

    assert pk == "the-object"

    obj1 = model.objects.get()
    assert obj1.pk == "the-object"
    assert obj1.name == "the-object"
    assert obj1.cookies == "some-cookies"


def test_insert_on_conflict():
    """Tests whether inserts works when a conflict is anticipated."""


# Path: psqlextra/query.py
# class PostgresQuerySet(models.QuerySet):
#     def __init__(self, model=None, query=None, using=None, hints=None):
#     def annotate(self, **annotations):
#     def rename_annotations(self, **annotations):
#     def on_conflict(
#         self,
#         fields: ConflictTarget,
#         action: ConflictAction,
#         index_predicate: Optional[Union[Expression, Q, str]] = None,
#         update_condition: Optional[Union[Expression, Q, str]] = None,
#     ):
#     def bulk_insert(
#         self,
#         rows: List[dict],
#         return_model: bool = False,
#         using: Optional[str] = None,
#     ):
#     def insert(self, using: Optional[str] = None, **fields):
#     def insert_and_get(self, using: Optional[str] = None, **fields):
#     def upsert(
#         self,
#         conflict_target: ConflictTarget,
#         fields: dict,
#         index_predicate: Optional[Union[Expression, Q, str]] = None,
#         using: Optional[str] = None,
#         update_condition: Optional[Union[Expression, Q, str]] = None,
#     ) -> int:
#     def upsert_and_get(
#         self,
#         conflict_target: ConflictTarget,
#         fields: dict,
#         index_predicate: Optional[Union[Expression, Q, str]] = None,
#         using: Optional[str] = None,
#         update_condition: Optional[Union[Expression, Q, str]] = None,
#     ):
#     def bulk_upsert(
#         self,
#         conflict_target: ConflictTarget,
#         rows: Iterable[Dict],
#         index_predicate: Optional[Union[Expression, Q, str]] = None,
#         return_model: bool = False,
#         using: Optional[str] = None,
#         update_condition: Optional[Union[Expression, Q, str]] = None,
#     ):
#         def is_empty(r):
#     def _create_model_instance(
#         self, field_values: dict, using: str, apply_converters: bool = True
#     ):
#     def _build_insert_compiler(
#         self, rows: Iterable[Dict], using: Optional[str] = None
#     ):
#     def _is_magical_field(self, model_instance, field, is_insert: bool):
#     def _get_upsert_fields(self, kwargs):
# 
# 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_insert.py
from django.db import models
from psqlextra.query import ConflictAction
from .fake_model import get_fake_model


    obj1 = model.objects.get()
    assert obj1.pk == pk
    assert obj1.cookies == "some-cookies"


def test_insert_explicit_pk():
    """Tests whether inserts works when the primary key is explicitly
    specified."""

    model = get_fake_model(
        {
            "name": models.CharField(max_length=255, primary_key=True),
            "cookies": models.CharField(max_length=255, null=True),
        }
    )

    pk = model.objects.all().insert(name="the-object", cookies="some-cookies")

    assert pk == "the-object"

    obj1 = model.objects.get()
    assert obj1.pk == "the-object"
    assert obj1.name == "the-object"
    assert obj1.cookies == "some-cookies"


def test_insert_on_conflict():
    """Tests whether inserts works when a conflict is anticipated."""


    model = get_fake_model(