<commit_before>var util           = require("util");
var events         = require("events");
var path           = require("path");
var Query          = require("sql-query");

var Model          = require("./Model").Model;
var DriverAliases  = require("./Drivers/aliases");
var Validators     = require("./Validators");
var Property       = require("./Property");
var Settings       = require("./Settings");

exports.validators = Validators;
exports.settings   = new Settings.Container(Settings.defaults());

for (var k in Query.Comparators) {
	exports[Query.Comparators[k]] = Query[Query.Comparators[k]];
}

exports.express = function () {
	return require("./Express").apply(this, arguments);
};

exports.use = function (connection, proto, opts, cb) {
	if (DriverAliases[proto]) {
		proto = DriverAliases[proto];
	}
	if (typeof opts == "function") {
		cb = opts;
		opts = {};
	}

	try {
		var Driver = require("./Drivers/DML/" + proto).Driver;
		var driver = new Driver(null, connection, {
			debug: (opts.query && opts.query.debug == 'true')
		});

		return cb(null, new ORM(driver, new Settings.Container(exports.settings.get('*'))));
	} catch (ex) {
		return cb(ex);
	}
};

exports.connect = function (opts, cb) {
	var url = require("url");

	if (typeof opts == "string") {
		if (opts.replace(/\s+/, "").length === 0) {
			return cb(new Error("CONNECTION_URL_EMPTY"));
		}
		opts = url.parse(opts, true);
	}
	if (!opts.database) {
		// if (!opts.pathname) {
		// 	return cb(new Error("CONNECTION_URL_NO_DATABASE"));
		// }
		opts.database = (opts.pathname ? opts.pathname.substr(1) : "");
	}
	if (!opts.protocol) {
		return cb(new Error("CONNECTION_URL_NO_PROTOCOL"));
	}
	if (!opts.host) {
		opts.host = opts.hostname = "localhost";
	}
	if (opts.auth) {
		opts.user = opts.auth.split(":")[0];
		opts.password = opts.auth.split(":")[1];
	}
	if (!opts.hasOwnProperty("user")) {
		opts.user = "root";
	}
	if (!opts.hasOwnProperty("password")) {<commit_msg>Fixes a regression when host is not defined and defaults to 'localhost' and makes sqlite not use memory db and instead creates 'localhost:' db in pwd()<commit_after>var util           = require("util");
var events         = require("events");
var path           = require("path");
var Query          = require("sql-query");

var Model          = require("./Model").Model;
var DriverAliases  = require("./Drivers/aliases");
var Validators     = require("./Validators");
var Property       = require("./Property");
var Settings       = require("./Settings");

exports.validators = Validators;
exports.settings   = new Settings.Container(Settings.defaults());

for (var k in Query.Comparators) {
	exports[Query.Comparators[k]] = Query[Query.Comparators[k]];
}

exports.express = function () {
	return require("./Express").apply(this, arguments);
};

exports.use = function (connection, proto, opts, cb) {
	if (DriverAliases[proto]) {
		proto = DriverAliases[proto];
	}
	if (typeof opts == "function") {
		cb = opts;
		opts = {};
	}

	try {
		var Driver = require("./Drivers/DML/" + proto).Driver;
		var driver = new Driver(null, connection, {
			debug: (opts.query && opts.query.debug == 'true')
		});

		return cb(null, new ORM(driver, new Settings.Container(exports.settings.get('*'))));
	} catch (ex) {
		return cb(ex);
	}
};

exports.connect = function (opts, cb) {
	var url = require("url");

	if (typeof opts == "string") {
		if (opts.replace(/\s+/, "").length === 0) {
			return cb(new Error("CONNECTION_URL_EMPTY"));
		}
		opts = url.parse(opts, true);
	}
	if (!opts.database) {
		// if (!opts.pathname) {
		// 	return cb(new Error("CONNECTION_URL_NO_DATABASE"));
		// }
		opts.database = (opts.pathname ? opts.pathname.substr(1) : "");
	}
	if (!opts.protocol) {
		return cb(new Error("CONNECTION_URL_NO_PROTOCOL"));
	}
	// if (!opts.host) {
	// 	opts.host = opts.hostname = "localhost";
	// }
	if (opts.auth) {
		opts.user = opts.auth.split(":")[0];
		opts.password = opts.auth.split(":")[1];
	}
	if (!opts.hasOwnProperty("user")) {
		opts.user = "root";
	}
	if (!opts.hasOwnProperty("password")) {
{'fraction_non_alphanumeric': 0.18936222605269637, 'fraction_numerical': 0.0019699581383895593, 'mean_word_length': 3.579481397970688, 'pattern_counts': {'":': 4, '<': 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': '6216599', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1361, 'n_words': 301}