<commit_before>/**
 * User: <NAME>
 * Date: 10/2/2014
 */

module Ground {

  export class Field_List implements Internal_Query_Source {

    source:Query_Builder
    properties
    derived_properties
    //all_properties
    fields:any[] = []
    joins:string[] = []
    trellises = {}
    reference_hierarchy:Embedded_Reference[] = []
    all_references:Embedded_Reference[] = []
    reference_join_count = 0

    constructor(source:Query_Builder) {
      this.source = source
      //this.all_properties = source.get_properties()
      this.properties = source.get_field_properties()
      this.derived_properties = Field_List.get_derived_properties(source.trellis)
      var name

      if (source.map && Object.keys(source.map).length > 0) {
        this.map_fields()
      }
      else {
        for (name in this.properties) {
          this.render_field(this.properties[name])
        }
      }

      for (name in this.trellises) {
        var trellis = this.trellises[name];
        var join = source.trellis.get_ancestor_join(trellis);
        if (join)
          this.joins.push(join);
      }
    }

    private render_field(property:Property) {
      var sql = property.is_virtual
        ? property.query_virtual_field()<commit_msg>Fixed a bug with JOIN order when using field mapping.<commit_after>/**
 * User: <NAME>
 * Date: 10/2/2014
 */

module Ground {

  export class Field_List implements Internal_Query_Source {

    source:Query_Builder
    properties
    derived_properties
    //all_properties
    fields:any[] = []
    joins:string[] = []
    trellises = {}
    reference_hierarchy:Embedded_Reference[] = []
    all_references:Embedded_Reference[] = []
    reference_join_count = 0

    constructor(source:Query_Builder) {
      this.source = source
      //this.all_properties = source.get_properties()
      this.properties = source.get_field_properties()
      this.derived_properties = Field_List.get_derived_properties(source.trellis)
      var name

      if (source.map && Object.keys(source.map).length > 0) {
        this.map_fields()
      }
      else {
        for (name in this.properties) {
          this.render_field(this.properties[name])
        }
      }

      this.generate_ancestor_joins(source)
    }

    private generate_ancestor_joins(source) {
      var ancestor_joins = []
      for (name in this.trellises) {
        var trellis = this.trellises[name];
        var join = source.trellis.get_ancestor_join(trellis);
        if (join)
          ancestor_joins.push(join);
      }
      this.joins = ancestor_joins.concat(this.joins)
    }

    private render_field(property:Property) {
      var sql = property.is_virtual
        ? property.query_virtual_field()
{'fraction_non_alphanumeric': 0.10599926389400073, 'fraction_numerical': 0.006624953993375046, 'mean_word_length': 2.668016194331984, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5181355', 'n_tokens_mistral': 866, 'n_tokens_neox': 828, 'n_words': 143}