django.db.NotSupportedError - python examples

Here are the examples of the python api django.db.NotSupportedError taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

15 Examples 7

3 View Complete Implementation : operations.py
Copyright GNU Lesser General Public License v3.0
Author : opentaps
    def window_frame_range_start_end(self, start=None, end=None):
        start_, end_ = super().window_frame_range_start_end(start, end)
        if (start and start < 0) or (end and end > 0):
            raise NotSupportedError(
                'PostgreSQL only supports UNBOUNDED together with PRECEDING '
                'and FOLLOWING.'
            )
        return start_, end_

3 View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : raphaelm
    def as_sql(self, qn, connection):
        if '.postgresql' in connection.settings_dict['ENGINE']:
            return super().as_sql(qn, connection)
        raise NotSupportedError(
            'Lookups on JSONFields are only supported on PostgreSQL and MySQL at the moment.'
        )

3 View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : raphaelm
    def as_sql(self, qn, connection):
        if '.postgresql' in connection.settings_dict['ENGINE']:
            return super().as_sql(qn, connection)
        if '.mysql' in connection.settings_dict['ENGINE']:
            lhs, lhs_params = self.process_lhs(qn, connection)
            rhs, rhs_params = self.process_rhs(qn, connection)
            for i, p in enumerate(rhs_params):
                rhs_params[i] = p.dumps(p.adapted)  # Convert JSONAdapter to str
            params = lhs_params + rhs_params
            return 'JSON_CONTAINS({}, {})'.format(lhs, rhs), params
        raise NotSupportedError('Lookup not supported for %s' % connection.settings_dict['ENGINE'])

3 View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : raphaelm
    def as_sql(self, qn, connection):
        if '.postgresql' in connection.settings_dict['ENGINE']:
            return super().as_sql(qn, connection)
        if '.mysql' in connection.settings_dict['ENGINE']:
            lhs, lhs_params = self.process_lhs(qn, connection)
            rhs, rhs_params = self.process_rhs(qn, connection)
            for i, p in enumerate(rhs_params):
                rhs_params[i] = p.dumps(p.adapted)  # Convert JSONAdapter to str
            params = rhs_params + lhs_params
            return 'JSON_CONTAINS({}, {})'.format(rhs, lhs), params
        raise NotSupportedError('Lookup not supported for %s' % connection.settings_dict['ENGINE'])

3 View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : raphaelm
    def as_sql(self, qn, connection):
        if '.postgresql' in connection.settings_dict['ENGINE']:
            return super().as_sql(qn, connection)
        if '.mysql' in connection.settings_dict['ENGINE']:
            lhs, lhs_params = self.process_lhs(qn, connection)
            key_name = self.rhs
            path = '$.{}'.format(json.dumps(key_name))
            params = lhs_params + [path]
            return "JSON_CONTAINS_PATH({}, 'one', %s)".format(lhs), params
        raise NotSupportedError('Lookup not supported for %s' % connection.settings_dict['ENGINE'])

3 View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : raphaelm
    def as_sql(self, qn, connection):
        if '.postgresql' in connection.settings_dict['ENGINE']:
            return super().as_sql(qn, connection)
        if '.mysql' in connection.settings_dict['ENGINE']:
            lhs, lhs_params = self.process_lhs(qn, connection)
            paths = [
                '$.{}'.format(json.dumps(key_name))
                for key_name in self.rhs
            ]
            params = lhs_params + paths

            sql = ['JSON_CONTAINS_PATH(', lhs, ", 'all', "]
            sql.append(', '.join('%s' for _ in paths))
            sql.append(')')
            return ''.join(sql), params
        raise NotSupportedError('Lookup not supported for %s' % connection.settings_dict['ENGINE'])

3 View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : raphaelm
    def as_sql(self, qn, connection):
        if '.postgresql' in connection.settings_dict['ENGINE']:
            return super().as_sql(qn, connection)
        if '.mysql' in connection.settings_dict['ENGINE']:
            lhs, lhs_params = self.process_lhs(qn, connection)
            paths = [
                '$.{}'.format(json.dumps(key_name))
                for key_name in self.rhs
            ]
            params = lhs_params + paths

            sql = ['JSON_CONTAINS_PATH(', lhs, ", 'one', "]
            sql.append(', '.join('%s' for _ in paths))
            sql.append(')')
            return ''.join(sql), params
        raise NotSupportedError('Lookup not supported for %s' % connection.settings_dict['ENGINE'])

3 View Complete Implementation : fields.py
Copyright Apache License 2.0
Author : raphaelm
    def as_sql(self, compiler, connection):
        if '.postgresql' in connection.settings_dict['ENGINE']:
            return super().as_sql(compiler, connection)
        elif '.mysql' in connection.settings_dict['ENGINE']:
            key_transforms = [self.key_name]
            previous = self.lhs
            while isinstance(previous, FallbackKeyTransform):
                key_transforms.insert(0, previous.key_name)
                previous = previous.lhs

            lhs, params = compiler.compile(previous)
            json_path = mysql_compile_json_path(key_transforms)
            return 'JSON_EXTRACT({}, %s)'.format(lhs), params + [json_path]

        raise NotSupportedError(
            'Transforms on JSONFields are only supported on PostgreSQL and MySQL at the moment.'
        )

3 View Complete Implementation : operations.py
Copyright MIT License
Author : rizwansoaib
    def distinct_sql(self, fields, params):
        """
        Return an SQL DISTINCT clause which removes duplicate rows from the
        result set. If any fields are given, only check the given fields for
        duplicates.
        """
        if fields:
            raise NotSupportedError('DISTINCT ON fields is not supported by this database backend')
        else:
            return ['DISTINCT'], []

3 View Complete Implementation : operations.py
Copyright MIT License
Author : rizwansoaib
    def subtract_temporals(self, internal_type, lhs, rhs):
        if self.connection.features.supports_temporal_subtraction:
            lhs_sql, lhs_params = lhs
            rhs_sql, rhs_params = rhs
            return "(%s - %s)" % (lhs_sql, rhs_sql), lhs_params + rhs_params
        raise NotSupportedError("This backend does not support %s subtraction." % internal_type)