<commit_before>#encoding=utf-8
from . import statements
from . import grouping
from . import expressions
import json

class Select:
    """SELECT Query Builder"""
    def __init__(self, *fields):
        """
        Inicializa la consulta SELECT opcionalmente los argumentos pasados serna considerados campos para la proyección.
        """
        super(self.__class__, self).__init__()
        self.raw_fields = fields
        self.raw_fields = []
        self.raw_fields_group = []
        self.fields = []
        self.group_fields = []
        self.raw_tables = []
        self.raw_order_by = []
        self.order_by_fields = []
        self.tables = []
        self.where_criteria = grouping.BaseGrouper()

    def __prepareData__(self):
        """
        Helper para preparar los datos para la produccion del SQL final.
        """
        if isinstance(self.raw_fields, str):
            self.raw_fields = self.raw_fields.split(',')

        for x in self.raw_fields:
            self.fields.append(expressions.AliasExpression(x).result())
        
        if len(self.fields) == 0:
            self.fields.append('*')

        for x in self.raw_tables:
            self.tables.append(expressions.AliasExpression(x).result())

        if isinstance(self.raw_fields_group, str):
            self.raw_fields_group = self.raw_fields_group.split(',')


        for x in self.raw_fields_group:
            self.group_fields.append(expressions.AliasExpression(x).result())


        if isinstance(self.raw_order_by, str):
            self.raw_order_by = self.raw_order_by.split(',')

        for x in self.raw_order_by:
            self.order_by_fields.append(expressions.OrderByExpression(*x).result())

    def from_(self, table, alias=None):
        """
        Establece el origen de datos (y un alias opcionalmente).
        """
        if isinstance(table, str):
            table = [[table, alias]]
        self.raw_tables = table
        return self

    def where(self, field, value = None, operator = None):
        """
        Establece condiciones para la consulta unidas por AND
        """
        if field is None:
            return self
        conjunction = None
        if value is None and isinstance(field, dict):
            for f,vo in field.items():
                if self.where_criteria.size() > 0:
                    conjunction = 'AND'
                try:
                	operator, v = vo
                except Exception as e:
                	v = vo
                	operator = None
                self.where_criteria.append(expressions.ConditionExpression(f, v, operator=operator, conjunction=conjunction))
                
        else:
            if self.where_criteria.size() > 0:
                    conjunction = 'AND'
            self.where_criteria.append(expressions.ConditionExpression(field, value, operator=operator, conjunction=conjunction))
        return self

    def where_or(self, field, value = None, operator = None):
        """
        Establece condiciones para la consulta unidas por OR
        """
        if field is None:
            return self
        conjunction = None
        if value is None and isinstance(field, dict):
            for f,v in field.items():
                if self.where_criteria.size() > 0:
                    conjunction = 'OR'

                self.where_criteria.append(expressions.ConditionExpression(f, v, operator=operator, conjunction=conjunction))
                
        else:
            if self.where_criteria.size() > 0:
                    conjunction = 'OR'
            self.where_criteria.append(expressions.ConditionExpression(field, value, operator=operator, conjunction=conjunction))<commit_msg>cambios<commit_after>#encoding=utf-8
from . import statements
from . import grouping
from . import expressions
import json

class Select:
    """SELECT Query Builder"""
    def __init__(self, *fields):
        """
        Inicializa la consulta SELECT opcionalmente los argumentos pasados serna considerados campos para la proyección.
        """
        super(self.__class__, self).__init__()
        self.raw_fields = fields
        self.raw_fields = []
        self.raw_fields_group = []
        self.fields = []
        self.group_fields = []
        self.raw_tables = []
        self.raw_order_by = []
        self.order_by_fields = []
        self.tables = []
        self.where_criteria = grouping.BaseGrouper()

    def __prepareData__(self):
        """
        Helper para preparar los datos para la produccion del SQL final.
        """
        if isinstance(self.raw_fields, str):
            self.raw_fields = self.raw_fields.split(',')

        for x in self.raw_fields:
            self.fields.append(expressions.AliasExpression(x).result())
        
        if len(self.fields) == 0:
            self.fields.append('*')

        for x in self.raw_tables:
            self.tables.append(expressions.AliasExpression(x).result())

        if isinstance(self.raw_fields_group, str):
            self.raw_fields_group = self.raw_fields_group.split(',')


        for x in self.raw_fields_group:
            self.group_fields.append(expressions.AliasExpression(x).result())


        if isinstance(self.raw_order_by, str):
            self.raw_order_by = self.raw_order_by.split(',')

        for x in self.raw_order_by:
            self.order_by_fields.append(expressions.OrderByExpression(*x).result())

    def from_(self, table, alias=None):
        """
        Establece el origen de datos (y un alias opcionalmente).
        """
        if isinstance(table, str):
            table = [[table, alias]]
        self.raw_tables = table
        return self

    def where(self, field, value = None, operator = None):
        """
        Establece condiciones para la consulta unidas por AND
        """
        if field is None:
            return self
        conjunction = None
        if value is None and isinstance(field, dict):
            for f,vo in field.items():
                if self.where_criteria.size() > 0:
                    conjunction = 'AND'
                try:
                    operator, v = vo
                except Exception as e:
                    v = vo
                    operator = None
                self.where_criteria.append(expressions.ConditionExpression(f, v, operator=operator, conjunction=conjunction))
                
        else:
            if self.where_criteria.size() > 0:
                    conjunction = 'AND'
            self.where_criteria.append(expressions.ConditionExpression(field, value, operator=operator, conjunction=conjunction))
        return self

    def where_or(self, field, value = None, operator = None):
        """
        Establece condiciones para la consulta unidas por OR
        """
        if field is None:
            return self
        conjunction = None
        if value is None and isinstance(field, dict):
            for f,v in field.items():
                if self.where_criteria.size() > 0:
                    conjunction = 'OR'

                self.where_criteria.append(expressions.ConditionExpression(f, v, operator=operator, conjunction=conjunction))
                
        else:
            if self.where_criteria.size() > 0:
                    conjunction = 'OR'
            self.where_criteria.append(expressions.ConditionExpression(field, value, operator=operator, conjunction=conjunction))
{'fraction_non_alphanumeric': 0.09626533638937576, 'fraction_numerical': 0.0016179048132668194, 'mean_word_length': 1.9459888800635425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '6561454', 'n_tokens_mistral': 2047, 'n_tokens_neox': 1967, 'n_words': 485}