<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace DataCore
{
    public class Query<T>
    {
        private readonly ITranslator _translator;

        public string TableName { get; private set; }

        public bool Built { get; private set; }

        public string SqlSelectFormat { get; set; }
        public string SqlColumns { get; set; }
        public string SqlFrom { get; set; }
        public string SqlWhere { get; set; }
        public StringBuilder SqlCommand { get; private set; }

        public Query(ITranslator translator)
        {
            Built = false;

            _translator = translator;
            SqlSelectFormat = "{0}";
            SqlWhere = string.Empty;
            SqlCommand = new StringBuilder();
            SqlColumns = "*";
            SqlFrom = typeof(T).Name;
            TableName = typeof(T).Name;
            SqlFrom = TableName;
        }

        public Query<T> Build()
        {
            // run the query
            SqlCommand.Append("SELECT ");
            SqlCommand.AppendFormat(SqlSelectFormat, SqlColumns);
            SqlCommand.Append(" FROM ");
            SqlCommand.Append(SqlFrom);

            var where = SqlWhere;
            if (!string.IsNullOrWhiteSpace(where))
                SqlCommand.AppendFormat(" WHERE {0}", where);

            Built = true;<commit_msg>Removing duplicated SqlFrom in Query constructor.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

namespace DataCore
{
    public class Query<T>
    {
        private readonly ITranslator _translator;

        public string TableName { get; private set; }

        public bool Built { get; private set; }

        public string SqlSelectFormat { get; set; }
        public string SqlColumns { get; set; }
        public string SqlFrom { get; set; }
        public string SqlWhere { get; set; }
        public StringBuilder SqlCommand { get; private set; }

        public Query(ITranslator translator)
        {
            Built = false;

            _translator = translator;
            SqlSelectFormat = "{0}";
            SqlWhere = string.Empty;
            SqlCommand = new StringBuilder();
            SqlColumns = "*";
            TableName = typeof(T).Name;
            SqlFrom = TableName;
        }

        public Query<T> Build()
        {
            // run the query
            SqlCommand.Append("SELECT ");
            SqlCommand.AppendFormat(SqlSelectFormat, SqlColumns);
            SqlCommand.Append(" FROM ");
            SqlCommand.Append(SqlFrom);

            var where = SqlWhere;
            if (!string.IsNullOrWhiteSpace(where))
                SqlCommand.AppendFormat(" WHERE {0}", where);

            Built = true;
{'fraction_non_alphanumeric': 0.09154437456324249, 'fraction_numerical': 0.001397624039133473, 'mean_word_length': 1.9364102564102563, 'pattern_counts': {'":': 0, '<': 7, '<?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': '759375', 'n_tokens_mistral': 732, 'n_tokens_neox': 711, 'n_words': 204}