# Path: pyston/utils/compatibility.py
# def get_last_parent_pk_field_name(obj):
#     for field in obj._meta.fields:
#         if field.primary_key and (not field.is_relation or not field.auto_created):
#             return field.name
#     raise RuntimeError('Last parent field name was not found (cannot happen)')


from chamber.patch import Options
from django.db import models
from django.db.models.fields import Field
from django.db.models.fields.related import ForeignKey, ManyToManyField, ForeignObjectRel
from pyston.utils.compatibility import get_last_parent_pk_field_name
import django.db.models.options as options




def merge_iterable(a, b):
    c = list(a) + list(b)
    return sorted(set(c), key=lambda x: c.index(x))


class RestOptions(Options):

    model_class = models.Model
    meta_class_name = 'RestMeta'
    meta_name = '_rest_meta'
    attributes = {}

    def __init__(self, model):
        super().__init__(model)

# Path: pyston/utils/compatibility.py
# def get_last_parent_pk_field_name(obj):
#     for field in obj._meta.fields:
#         if field.primary_key and (not field.is_relation or not field.auto_created):
#             return field.name
#     raise RuntimeError('Last parent field name was not found (cannot happen)')


# Path: pyston/patch.py
from chamber.patch import Options
from django.db import models
from django.db.models.fields import Field
from django.db.models.fields.related import ForeignKey, ManyToManyField, ForeignObjectRel
from pyston.utils.compatibility import get_last_parent_pk_field_name
import django.db.models.options as options





def merge_iterable(a, b):
    c = list(a) + list(b)
    return sorted(set(c), key=lambda x: c.index(x))


class RestOptions(Options):

    model_class = models.Model
    meta_class_name = 'RestMeta'
    meta_name = '_rest_meta'
    attributes = {}

    def __init__(self, model):
        super().__init__(model)

        pk_field_name = get_last_parent_pk_field_name(model)