How to use the djangoql.exceptions.DjangoQLSchemaError function in djangoql

To help you get started, we’ve selected a few djangoql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ivelum / djangoql / djangoql / schema.py View on Github external
def resolve_name(self, name):
        assert isinstance(name, Name)
        model = self.model_label(self.current_model)
        field = None
        for name_part in name.parts:
            field = self.models[model].get(name_part)
            if not field:
                raise DjangoQLSchemaError(
                    'Unknown field: %s. Possible choices are: %s' % (
                        name_part,
                        ', '.join(sorted(self.models[model].keys())),
                    )
                )
            if field.type == 'relation':
                model = field.relation
                field = None
        return field
github ivelum / djangoql / djangoql / schema.py View on Github external
def __init__(self, model):
        if not inspect.isclass(model) or not issubclass(model, models.Model):
            raise DjangoQLSchemaError(
                'Schema must be initialized with a subclass of Django model'
            )
        if self.include and self.exclude:
            raise DjangoQLSchemaError(
                'Either include or exclude can be specified, but not both'
            )
        if self.excluded(model):
            raise DjangoQLSchemaError(
                "%s can't be used with %s because it's excluded from it" % (
                    model,
                    self.__class__,
                )
            )
        self.current_model = model
        self._models = None
        if self.suggest_options is None:
            self.suggest_options = {}
github ivelum / djangoql / djangoql / schema.py View on Github external
def __init__(self, model):
        if not inspect.isclass(model) or not issubclass(model, models.Model):
            raise DjangoQLSchemaError(
                'Schema must be initialized with a subclass of Django model'
            )
        if self.include and self.exclude:
            raise DjangoQLSchemaError(
                'Either include or exclude can be specified, but not both'
            )
        if self.excluded(model):
            raise DjangoQLSchemaError(
                "%s can't be used with %s because it's excluded from it" % (
                    model,
                    self.__class__,
                )
            )
        self.current_model = model
        self._models = None
        if self.suggest_options is None:
            self.suggest_options = {}
github ivelum / djangoql / djangoql / schema.py View on Github external
def __init__(self, model):
        if not inspect.isclass(model) or not issubclass(model, models.Model):
            raise DjangoQLSchemaError(
                'Schema must be initialized with a subclass of Django model'
            )
        if self.include and self.exclude:
            raise DjangoQLSchemaError(
                'Either include or exclude can be specified, but not both'
            )
        if self.excluded(model):
            raise DjangoQLSchemaError(
                "%s can't be used with %s because it's excluded from it" % (
                    model,
                    self.__class__,
                )
            )
        self.current_model = model
        self._models = None
        if self.suggest_options is None:
github ivelum / djangoql / djangoql / schema.py View on Github external
'can\'t compare it to None' % self.name
            )
        if value is not None and type(value) not in self.value_types:
            if self.nullable:
                msg = (
                    'Field "{field}" has "nullable {field_type}" type. '
                    'It can be compared to {possible_values} or None, '
                    'but not to {value}'
                )
            else:
                msg = (
                    'Field "{field}" has "{field_type}" type. It can '
                    'be compared to {possible_values}, '
                    'but not to {value}'
                )
            raise DjangoQLSchemaError(msg.format(
                field=self.name,
                field_type=self.type,
                possible_values=self.value_types_description,
                value=repr(value),
            ))