<commit_before>var Model             = require('model');
var DbCommand         = require('db/db_command');
var DbCriteria        = require('db/db_criteria');
var Emitter           = process.EventEmitter;
var ActiveFinder      = require('./active_finder');
var tools             = require( 'lib/tools' );
var active_relations  = {
  belongs_to  : require('./relations/belongs_to_relation'),
  stat        : require('./relations/stat_relation'),
  has_one     : require('./relations/has_one_relation'),
  has_many    : require('./relations/has_many_relation'),
  many_many   : require('./relations/many_many_relation')
};

module.exports = ActiveRecord.inherits( Model );

function ActiveRecord() {
  throw new Error( 'ActiveRecord is abstract class. You can\'t instantiate it!' );
}


ActiveRecord._relations = null;


ActiveRecord.prototype._init = function( params ) {
  this.super_._init( params );

  this._.is_inited  = false;
  this._.table_name = this.constructor.table_name;

  if ( !this.table_name )
    throw new Error( 'You should specify `table_name` property for ' + this.class_name );

  this._.db_connection  = this.app.db;
  if ( !this.db_connection )
    throw new Error(
      'Looks like you don\'t preload or config `db` component, but it\'s required for use ActiveRecord class `%s`'.format( this.class_name )
    );

  this._.table          = null;

  this._related         = {};
  this._alias           = 't';
  this._criteria        = null;

  var self = this;

  this.db_connection.db_schema.get_table( this.table_name, function( err, table ) {
    if ( err ) throw err;

    this._.table      = table;
    this._.is_inited  = true;
    this.emit( 'initialized' );
  }, this );

  this.app.on( 'models_loaded', function() {<commit_msg>erron on get table more informative<commit_after>var Model             = require('model');
var DbCommand         = require('db/db_command');
var DbCriteria        = require('db/db_criteria');
var Emitter           = process.EventEmitter;
var ActiveFinder      = require('./active_finder');
var tools             = require( 'lib/tools' );
var active_relations  = {
  belongs_to  : require('./relations/belongs_to_relation'),
  stat        : require('./relations/stat_relation'),
  has_one     : require('./relations/has_one_relation'),
  has_many    : require('./relations/has_many_relation'),
  many_many   : require('./relations/many_many_relation')
};

module.exports = ActiveRecord.inherits( Model );

function ActiveRecord() {
  throw new Error( 'ActiveRecord is abstract class. You can\'t instantiate it!' );
}


ActiveRecord._relations = null;


ActiveRecord.prototype._init = function( params ) {
  this.super_._init( params );

  this._.is_inited  = false;
  this._.table_name = this.constructor.table_name;

  if ( !this.table_name )
    throw new Error( 'You should specify `table_name` property for ' + this.class_name );

  this._.db_connection  = this.app.db;
  if ( !this.db_connection )
    throw new Error(
      'Looks like you don\'t preload or config `db` component, but it\'s required for use ActiveRecord class `%s`'.format( this.class_name )
    );

  this._.table          = null;

  this._related         = {};
  this._alias           = 't';
  this._criteria        = null;

  var self = this;

  this.db_connection.db_schema.get_table( this.table_name, function( err, table ) {
    if ( err ) {
      err.message = 'Error while loading table `%s`. '.format( this.table_name ) + err.message;
      throw err;
    }

    this._.table      = table;
    this._.is_inited  = true;
    this.emit( 'initialized' );
  }, this );

  this.app.on( 'models_loaded', function() {
{'fraction_non_alphanumeric': 0.13232876712328767, 'fraction_numerical': 0.0, 'mean_word_length': 2.947027027027027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4801306', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1113, 'n_words': 262}