<commit_before>var Sequelize      = require('sequelize');
var breeze         = require("breeze-client");
var Promise        = require("bluebird");

var MetadataMapper = require('./MetadataMapper.js');
var dbUtils        = require('./dbUtils.js');
var utils          = require('./utils.js');

var _             = Sequelize.Utils._;
var log = utils.log;

module.exports = SequelizeManager;

function SequelizeManager(dbConfig, sequelizeOptions) {
  var defaultOptions = {
    dialect: "mysql", // or 'sqlite', 'postgres', 'mariadb'
    port: 3306, // or 5432 (for postgres)
    // omitNull: true,
    logging: console.log
  };
  this.sequelizeOptions = _.extend(defaultOptions, sequelizeOptions || {});
  this.dbConfig = dbConfig;
  this.sequelize = new Sequelize(dbConfig.dbName, dbConfig.user, dbConfig.password, this.sequelizeOptions);
}

// Expose Sequelize from outside
SequelizeManager.Sequelize = Sequelize;

// returns Promise(null);
SequelizeManager.prototype.authenticate = function() {
  // check database connection
  return this.sequelize.authenticate().then(function() {
    log('Connection has been established successfully.');
  }).error(function(err) {
    log('Unable to connect to the database:', err);
    throw err;
  });

};

SequelizeManager.prototype.createDb = function() {
  return dbUtils.createDb(this.dbConfig, this.sequelizeOptions);
};

SequelizeManager.prototype.importMetadata = function(breezeMetadata) {
  var metadataMapper = new MetadataMapper(breezeMetadata, this.sequelize);
  // TODO: should we merge here instead ; i.e. allow multiple imports...
  this.models = this.resourceNameSqModelMap = metadataMapper.resourceNameSqModelMap;
  this.entityTypeSqModelMap = metadataMapper.entityTypeSqModelMap;
  this.metadataStore = metadataMapper.metadataStore;

};

// returns Promise(sequelize);
SequelizeManager.prototype.sync = function(shouldCreateDb, sequelizeOpts) {
  if (shouldCreateDb) {
    var that = this;
    return this.createDb().then(function() {
      return syncCore(that.sequelize);
    });
  } else {
    return syncCore(this.sequelize);
  }
};
<commit_msg>fix sequelize sync options - do not forget to pass them on<commit_after>var Sequelize      = require('sequelize');
var breeze         = require("breeze-client");
var Promise        = require("bluebird");

var MetadataMapper = require('./MetadataMapper.js');
var dbUtils        = require('./dbUtils.js');
var utils          = require('./utils.js');

var _             = Sequelize.Utils._;
var log = utils.log;

module.exports = SequelizeManager;

function SequelizeManager(dbConfig, sequelizeOptions) {
  var defaultOptions = {
    dialect: "mysql", // or 'sqlite', 'postgres', 'mariadb'
    port: 3306, // or 5432 (for postgres)
    // omitNull: true,
    logging: console.log
  };
  this.sequelizeOptions = _.extend(defaultOptions, sequelizeOptions || {});
  this.dbConfig = dbConfig;
  this.sequelize = new Sequelize(dbConfig.dbName, dbConfig.user, dbConfig.password, this.sequelizeOptions);
}

// Expose Sequelize from outside
SequelizeManager.Sequelize = Sequelize;

// returns Promise(null);
SequelizeManager.prototype.authenticate = function() {
  // check database connection
  return this.sequelize.authenticate().then(function() {
    log('Connection has been established successfully.');
  }).error(function(err) {
    log('Unable to connect to the database:', err);
    throw err;
  });

};

SequelizeManager.prototype.createDb = function() {
  return dbUtils.createDb(this.dbConfig, this.sequelizeOptions);
};

SequelizeManager.prototype.importMetadata = function(breezeMetadata) {
  var metadataMapper = new MetadataMapper(breezeMetadata, this.sequelize);
  // TODO: should we merge here instead ; i.e. allow multiple imports...
  this.models = this.resourceNameSqModelMap = metadataMapper.resourceNameSqModelMap;
  this.entityTypeSqModelMap = metadataMapper.entityTypeSqModelMap;
  this.metadataStore = metadataMapper.metadataStore;

};

// returns Promise(sequelize);
SequelizeManager.prototype.sync = function(shouldCreateDb, sequelizeOpts) {
  if (shouldCreateDb) {
    var that = this;
    return this.createDb().then(function() {
      return syncCore(that.sequelize, sequelizeOpts);
    });
  } else {
    return syncCore(this.sequelize, sequelizeOpts);
  }
};

{'fraction_non_alphanumeric': 0.12479589456496384, 'fraction_numerical': 0.0037322136692325637, 'mean_word_length': 4.160048134777377, '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': '7575883', 'n_tokens_mistral': 1318, 'n_tokens_neox': 1302, 'n_words': 278}