# Path: querybuilder/fields.py
# class FieldFactory(object):
#     """
#     Creates the correct field class based on the type of the passed field
#     """
# 
#     def __new__(cls, field, *args, **kwargs):
#         """
#         Determines which type of field class to instantiate based on the field argument
# 
#         :param field: The field used in determining which type of Field object to return.
#             This can be a string of the field name, a dict of {'alias': field},
#             or a ``Field``
#         :type table: str or dict or :class:`Field <querybuilder.fields.Field>`
# 
#         :return: The Field instance if a valid type was determined, otherwise None
#         :rtype: :class:`Field <querybuilder.fields.Field>` or None
#         """
#         field_type = type(field)
#         if field_type is dict:
#             kwargs.update(alias=list(field.keys())[0])
#             field = list(field.values())[0]
#             field_type = type(field)
# 
#         if isinstance(field, string_types):
#             return SimpleField(field, **kwargs)
#         elif isinstance(field, Field):
#             for key, value in kwargs.items():
#                 setattr(field, key, value)
#             return field
#         return None


import abc
import querybuilder
from django.db.models.base import ModelBase
from six import string_types, with_metaclass
from querybuilder.fields import FieldFactory
        Loop through this tables fields and calls the get_identifier
        method on each of them to build a list of field identifiers

        :returns: A list of field identifiers found in this table
        :rtype: list of str
        """
        return [field.get_identifier() for field in self.fields]

    def get_field_prefix(self):
        """
        Gets the prefix to be used in front of each field. If no prefix is
        set, then the identifier for this table is returned

        :returns: The field prefix for this table
        :rtype: str
        """
        return self.field_prefix or self.get_identifier()

    def find_field(self, field=None, alias=None):
        """
        Finds a field by name or alias.

        :param field: string of the field name or alias, dict of {'alias': field}, or a Field instance
        :type field: str or dict or Field

        :returns: The field if it is found, otherwise None
        :rtype: :class:`Field <querybuilder.fields.Field>` or None
        """
        if alias:
            field = alias

# Path: querybuilder/fields.py
# class FieldFactory(object):
#     """
#     Creates the correct field class based on the type of the passed field
#     """
# 
#     def __new__(cls, field, *args, **kwargs):
#         """
#         Determines which type of field class to instantiate based on the field argument
# 
#         :param field: The field used in determining which type of Field object to return.
#             This can be a string of the field name, a dict of {'alias': field},
#             or a ``Field``
#         :type table: str or dict or :class:`Field <querybuilder.fields.Field>`
# 
#         :return: The Field instance if a valid type was determined, otherwise None
#         :rtype: :class:`Field <querybuilder.fields.Field>` or None
#         """
#         field_type = type(field)
#         if field_type is dict:
#             kwargs.update(alias=list(field.keys())[0])
#             field = list(field.values())[0]
#             field_type = type(field)
# 
#         if isinstance(field, string_types):
#             return SimpleField(field, **kwargs)
#         elif isinstance(field, Field):
#             for key, value in kwargs.items():
#                 setattr(field, key, value)
#             return field
#         return None


# Path: querybuilder/tables.py
import abc
import querybuilder
from django.db.models.base import ModelBase
from six import string_types, with_metaclass
from querybuilder.fields import FieldFactory

        Loop through this tables fields and calls the get_identifier
        method on each of them to build a list of field identifiers

        :returns: A list of field identifiers found in this table
        :rtype: list of str
        """
        return [field.get_identifier() for field in self.fields]

    def get_field_prefix(self):
        """
        Gets the prefix to be used in front of each field. If no prefix is
        set, then the identifier for this table is returned

        :returns: The field prefix for this table
        :rtype: str
        """
        return self.field_prefix or self.get_identifier()

    def find_field(self, field=None, alias=None):
        """
        Finds a field by name or alias.

        :param field: string of the field name or alias, dict of {'alias': field}, or a Field instance
        :type field: str or dict or Field

        :returns: The field if it is found, otherwise None
        :rtype: :class:`Field <querybuilder.fields.Field>` or None
        """
        if alias:
            field = alias

        field = FieldFactory(field, table=self, alias=alias)