<commit_before>'use strict';

/**
 Returns an object that treats MySQL's inabilities to do certain queries.

 @class QueryInterface
 @static
 */

const _ = require('lodash');

/**
  A wrapper that fixes MySQL's inability to cleanly remove columns from existing tables if they have a foreign key constraint.

  @method removeColumn
  @for    QueryInterface

  @param  {String} tableName     The name of the table.
  @param  {String} columnName    The name of the attribute that we want to remove.
  @param  {Object} options
 */
function removeColumn(tableName, columnName, options) {
  options = options || {};
  var tableNameSchema = tableName;
  /* jshint validthis:true */
  if(this.sequelize.config.database){
    tableNameSchema = {
      tableName: tableName,
      schema: this.sequelize.config.database
    };
  }

  /* jshint validthis:true */
  return this.sequelize.query(
      this.QueryGenerator.getForeignKeyQuery(tableNameSchema, columnName),
      _.assign({ raw: true }, options)
    )
    .spread(results => {
      if (!results.length) {
        // No foreign key constraints found, so we can remove the column
        return;
      }
      return this.sequelize.query(
        this.QueryGenerator.dropForeignKeyQuery(tableName, results[0].constraint_name),
        _.assign({ raw: true }, options)
      );
    })
    .then(() => this.sequelize.query(
      this.QueryGenerator.removeColumnQuery(tableName, columnName),
      _.assign({ raw: true }, options)
    ));<commit_msg>fix spaces<commit_after>'use strict';

/**
 Returns an object that treats MySQL's inabilities to do certain queries.

 @class QueryInterface
 @static
 */

const _ = require('lodash');

/**
  A wrapper that fixes MySQL's inability to cleanly remove columns from existing tables if they have a foreign key constraint.

  @method removeColumn
  @for    QueryInterface

  @param  {String} tableName     The name of the table.
  @param  {String} columnName    The name of the attribute that we want to remove.
  @param  {Object} options
 */
function removeColumn(tableName, columnName, options) {
  options = options || {};
  var tableNameSchema = tableName;
  /* jshint validthis:true */
  if (this.sequelize.config.database) {
    tableNameSchema = {
      tableName: tableName,
      schema: this.sequelize.config.database
    };
  }

  /* jshint validthis:true */
  return this.sequelize.query(
      this.QueryGenerator.getForeignKeyQuery(tableNameSchema, columnName),
      _.assign({ raw: true }, options)
    )
    .spread(results => {
      if (!results.length) {
        // No foreign key constraints found, so we can remove the column
        return;
      }
      return this.sequelize.query(
        this.QueryGenerator.dropForeignKeyQuery(tableName, results[0].constraint_name),
        _.assign({ raw: true }, options)
      );
    })
    .then(() => this.sequelize.query(
      this.QueryGenerator.removeColumnQuery(tableName, columnName),
      _.assign({ raw: true }, options)
    ));
{'fraction_non_alphanumeric': 0.10751252086811353, 'fraction_numerical': 0.000667779632721202, 'mean_word_length': 3.0817438692098094, 'pattern_counts': {'":': 0, '<': 3, '<?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': '4025443', 'n_tokens_mistral': 867, 'n_tokens_neox': 846, 'n_words': 250}