<commit_before>module.exports = (function(Nodal) {

  'use strict';

  const async = require('async');

  let expect = require('chai').expect;

  describe('Nodal.Composer', function() {

    let db = new Nodal.Database();

    let schemaParent = {
      table: 'parents',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'name', type: 'string'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    let schemaFriendship = {
      table: 'friendships',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'from_parent_id', type: 'int'},
        {name: 'to_parent_id', type: 'int'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    let schemaChild = {
      table: 'children',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'parent_id', type: 'int'},
        {name: 'name', type: 'string'},
        {name: 'age', type: 'int'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    let schemaPartner = {
      table: 'partners',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'parent_id', type: 'int'},
        {name: 'name', type: 'string'},
        {name: 'job', type: 'string'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    let schemaPet = {
      table: 'pets',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'parent_id', type: 'int'},
        {name: 'name', type: 'string'},
        {name: 'animal', type: 'string'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    class Parent extends Nodal.Model {}

    Parent.setDatabase(db);
    Parent.setSchema(schemaParent);
    Parent.joinsTo(Parent, {multiple: true, via: ['']});

    class Friendship extends Nodal.Model {}

    Friendship.setDatabase(db);
    Friendship.setSchema(schemaFriendship);
    Friendship.joinsTo(Parent, {via: ['from_parent_id', 'to_parent_id'], multiple: true});

    // Friendship.query()
    //   .filter({parent__id: 7})
    //   .join('parents'); // this makes sense
    //
    // Parent.query()
    //   .limit(1)
    //   .join('friendships')
    //   .join('parents')
    //
    // LEFT JOIN "friendships" AS "j1" ON (
    //   "j1"."from_parent_id" = "parents"."id" OR
    //   "j1"."to_parent_id" = "parents"."id" AND
    //   "j1"."from_parent_id" <> "j1"."to_parent_id"
    // )
    // LEFT JOIN "parents" AS "friendships" ON (
    //   "friendships"."id" = "j1"."from_parent_id" OR
    //   "friendships"."id" = "j1"."to_parent_id" AND
    //   "friendships"."id" <> "parents"."id"
    // )

    class Child extends Nodal.Model {}

    Child.setDatabase(db);
    Child.setSchema(schemaChild);
    Child.joinsTo(Parent, {multiple: true});

    class Partner extends Nodal.Model {}

    Partner.setDatabase(db);
    Partner.setSchema(schemaPartner);
    Partner.joinsTo(Parent);

    class Pet extends Nodal.Model {}

    Pet.setDatabase(db);
    Pet.setSchema(schemaPet);
    Pet.joinsTo(Parent, {multiple: true});

    before(function(done) {

      db.connect(Nodal.my.Config.db.main);
<commit_msg>remove commented examples<commit_after>module.exports = (function(Nodal) {

  'use strict';

  const async = require('async');

  let expect = require('chai').expect;

  describe('Nodal.Composer', function() {

    let db = new Nodal.Database();

    let schemaParent = {
      table: 'parents',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'name', type: 'string'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    let schemaFriendship = {
      table: 'friendships',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'from_parent_id', type: 'int'},
        {name: 'to_parent_id', type: 'int'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    let schemaChild = {
      table: 'children',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'parent_id', type: 'int'},
        {name: 'name', type: 'string'},
        {name: 'age', type: 'int'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    let schemaPartner = {
      table: 'partners',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'parent_id', type: 'int'},
        {name: 'name', type: 'string'},
        {name: 'job', type: 'string'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    let schemaPet = {
      table: 'pets',
      columns: [
        {name: 'id', type: 'serial'},
        {name: 'parent_id', type: 'int'},
        {name: 'name', type: 'string'},
        {name: 'animal', type: 'string'},
        {name: 'created_at', type: 'datetime'}
      ]
    };

    class Parent extends Nodal.Model {}

    Parent.setDatabase(db);
    Parent.setSchema(schemaParent);
    Parent.joinsTo(Parent, {multiple: true, via: ['']});

    class Friendship extends Nodal.Model {}

    Friendship.setDatabase(db);
    Friendship.setSchema(schemaFriendship);
    Friendship.joinsTo(Parent, {via: ['from_parent_id', 'to_parent_id'], multiple: true});

    class Child extends Nodal.Model {}

    Child.setDatabase(db);
    Child.setSchema(schemaChild);
    Child.joinsTo(Parent, {multiple: true});

    class Partner extends Nodal.Model {}

    Partner.setDatabase(db);
    Partner.setSchema(schemaPartner);
    Partner.joinsTo(Parent);

    class Pet extends Nodal.Model {}

    Pet.setDatabase(db);
    Pet.setSchema(schemaPet);
    Pet.joinsTo(Parent, {multiple: true});

    before(function(done) {

      db.connect(Nodal.my.Config.db.main);

{'fraction_non_alphanumeric': 0.18130874909616776, 'fraction_numerical': 0.0016268980477223427, 'mean_word_length': 2.501898734177215, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1423074', 'n_tokens_mistral': 1886, 'n_tokens_neox': 1807, 'n_words': 397}