<commit_before>from __future__ import unicode_literals

from django.db.backends.base.operations import BaseDatabaseOperations
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.db.backends.base.adapter import WKTAdapter
from django.contrib.gis.db.backends.base.operations import \
    BaseSpatialOperations
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.measure import Distance
from django.core.management.color import color_style
from django.utils import six
from django.utils.encoding import force_bytes, force_text


class HanaSpatialOperator(SpatialOperator):
    sql_template = "%(lhs)s.%(func)s(%(rhs)s)"

class HanaIsOneSpatialOperator(SpatialOperator):
    sql_template = "%(lhs)s.%(func)s(%(rhs)s) = 1"

class HanaIsValueSpatialOperator(SpatialOperator):
    sql_template = "%(lhs)s.%(func)s(%(rhs)s) %(op)s %%s"


class DatabaseOperations(BaseDatabaseOperations, BaseSpatialOperations):
    compiler_module = "django_hana.compiler"

    Adapter = WKTAdapter
    Adaptor = Adapter  # Backwards-compatibility alias.

    gis_operators = {
        'contains': HanaIsOneSpatialOperator(func='ST_CONTAINS'),
        'coveredby': HanaIsOneSpatialOperator(func='ST_COVEREDBY'),
        'covers': HanaIsOneSpatialOperator(func='ST_COVERS'),
        'crosses': HanaIsOneSpatialOperator(func='ST_CROSSES'),
        'disjoint': HanaIsOneSpatialOperator(func='ST_DISJOINT'),
        'distance': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='='),
        'distance_gt': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='>'),
        'distance_gte': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='>='),
        'distance_lt': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='<'),
        'distance_lte': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='<='),
        'equals': HanaIsOneSpatialOperator(func='ST_EQUALS'),
        'exact': HanaIsOneSpatialOperator(func='ST_EQUALS'),
        'intersects': HanaIsOneSpatialOperator(func='ST_INTERSECTS'),
        'overlaps': HanaIsOneSpatialOperator(func='ST_OVERLAPS'),
        'same_as': HanaIsOneSpatialOperator(func='ST_EQUALS'),
        'relate': HanaIsOneSpatialOperator(func='ST_RELATE'),
        'touches': HanaIsOneSpatialOperator(func='ST_TOUCHES'),
        'within': HanaIsValueSpatialOperator(func='ST_WITHINDISTANCE', op='<='),
    }

    def __init__(self, connection):
        super(DatabaseOperations, self).__init__(connection)

    def get_seq_name(self,table,column):
        return self.connection.default_schema+"_"+table+"_"+column+"_seq"

    def autoinc_sql(self, table, column):
        seq_name=self.quote_name(self.get_seq_name(table,column))
        column=self.quote_name(column)
        table=self.quote_name(table)
        seq_sql="""
CREATE SEQUENCE %(seq_name)s RESET BY SELECT IFNULL(MAX(%(column)s),0) + 1 FROM %(table)s
""" % locals()
        return [seq_sql]

    def date_extract_sql(self, lookup_type, field_name):<commit_msg>Remove schema from sequence name.<commit_after>from __future__ import unicode_literals

from django.db.backends.base.operations import BaseDatabaseOperations
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.db.backends.base.adapter import WKTAdapter
from django.contrib.gis.db.backends.base.operations import \
    BaseSpatialOperations
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.measure import Distance
from django.core.management.color import color_style
from django.utils import six
from django.utils.encoding import force_bytes, force_text


class HanaSpatialOperator(SpatialOperator):
    sql_template = "%(lhs)s.%(func)s(%(rhs)s)"

class HanaIsOneSpatialOperator(SpatialOperator):
    sql_template = "%(lhs)s.%(func)s(%(rhs)s) = 1"

class HanaIsValueSpatialOperator(SpatialOperator):
    sql_template = "%(lhs)s.%(func)s(%(rhs)s) %(op)s %%s"


class DatabaseOperations(BaseDatabaseOperations, BaseSpatialOperations):
    compiler_module = "django_hana.compiler"

    Adapter = WKTAdapter
    Adaptor = Adapter  # Backwards-compatibility alias.

    gis_operators = {
        'contains': HanaIsOneSpatialOperator(func='ST_CONTAINS'),
        'coveredby': HanaIsOneSpatialOperator(func='ST_COVEREDBY'),
        'covers': HanaIsOneSpatialOperator(func='ST_COVERS'),
        'crosses': HanaIsOneSpatialOperator(func='ST_CROSSES'),
        'disjoint': HanaIsOneSpatialOperator(func='ST_DISJOINT'),
        'distance': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='='),
        'distance_gt': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='>'),
        'distance_gte': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='>='),
        'distance_lt': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='<'),
        'distance_lte': HanaIsValueSpatialOperator(func='ST_DISTANCE', op='<='),
        'equals': HanaIsOneSpatialOperator(func='ST_EQUALS'),
        'exact': HanaIsOneSpatialOperator(func='ST_EQUALS'),
        'intersects': HanaIsOneSpatialOperator(func='ST_INTERSECTS'),
        'overlaps': HanaIsOneSpatialOperator(func='ST_OVERLAPS'),
        'same_as': HanaIsOneSpatialOperator(func='ST_EQUALS'),
        'relate': HanaIsOneSpatialOperator(func='ST_RELATE'),
        'touches': HanaIsOneSpatialOperator(func='ST_TOUCHES'),
        'within': HanaIsValueSpatialOperator(func='ST_WITHINDISTANCE', op='<='),
    }

    def __init__(self, connection):
        super(DatabaseOperations, self).__init__(connection)

    def get_seq_name(self,table,column):
        return '%s_%s_seq' % (table, column)

    def autoinc_sql(self, table, column):
        seq_name=self.quote_name(self.get_seq_name(table,column))
        column=self.quote_name(column)
        table=self.quote_name(table)
        seq_sql="""
CREATE SEQUENCE %(seq_name)s RESET BY SELECT IFNULL(MAX(%(column)s),0) + 1 FROM %(table)s
""" % locals()
        return [seq_sql]

    def date_extract_sql(self, lookup_type, field_name):
{'fraction_non_alphanumeric': 0.13012209399565144, 'fraction_numerical': 0.0010035122930255895, 'mean_word_length': 5.288117770767613, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5292282', 'n_tokens_mistral': 2058, 'n_tokens_neox': 2005, 'n_words': 293}