不要怂,就是干,撸起袖子干!

Commit 95adb78a by Felix Becker Committed by Mick Hansen

Remove dollar prefix from identifiers (#6289)

1 parent 53bbda5d
......@@ -514,9 +514,9 @@ class BelongsToMany extends Association {
if (instance instanceof association.target) {
return instance.where();
} else {
const $where = {};
$where[association.target.primaryKeyAttribute] = instance;
return $where;
const where = {};
where[association.target.primaryKeyAttribute] = instance;
return where;
}
});
......
......@@ -21,16 +21,16 @@ function addForeignKeyConstraints (newAttribute, source, target, options, key) {
// Find primary keys: composite keys not supported with this approach
const primaryKeys = Utils._.chain(source.rawAttributes).keys()
.filter($key => source.rawAttributes[$key].primaryKey)
.map($key => source.rawAttributes[$key].field || $key).value();
.filter(key => source.rawAttributes[key].primaryKey)
.map(key => source.rawAttributes[key].field || key).value();
if (primaryKeys.length === 1) {
if (!!source.$schema) {
if (!!source._schema) {
newAttribute.references = {
model: source.modelManager.sequelize.queryInterface.QueryGenerator.addSchema({
tableName: source.tableName,
$schema: source.$schema,
$schemaDelimiter: source.$schemaDelimiter
_schema: source._schema,
_schemaDelimiter: source._schemaDelimiter
})
};
} else {
......
......@@ -73,8 +73,8 @@ ABSTRACT.warn = function warn(link, text) {
}
};
ABSTRACT.prototype.stringify = function stringify(value, options) {
if (this.$stringify) {
return this.$stringify(value, options);
if (this._stringify) {
return this._stringify(value, options);
}
return value;
};
......@@ -361,7 +361,7 @@ DECIMAL.prototype.validate = function validate(value) {
for (const floating of [FLOAT, DOUBLE, REAL]) {
floating.prototype.escape = false;
floating.prototype.$stringify = function $stringify(value) {
floating.prototype._stringify = function _stringify(value) {
if (isNaN(value)) {
return "'NaN'";
} else if (!isFinite(value)) {
......@@ -435,7 +435,7 @@ DATE.prototype.validate = function validate(value) {
return true;
};
DATE.prototype.$applyTimezone = function $applyTimezone(date, options) {
DATE.prototype._applyTimezone = function _applyTimezone(date, options) {
if (options.timezone) {
if (momentTz.tz.zone(options.timezone)) {
date = momentTz(date).tz(options.timezone);
......@@ -449,8 +449,8 @@ DATE.prototype.$applyTimezone = function $applyTimezone(date, options) {
return date;
};
DATE.prototype.$stringify = function $stringify(date, options) {
date = this.$applyTimezone(date, options);
DATE.prototype._stringify = function _stringify(date, options) {
date = this._applyTimezone(date, options);
// Z here means current timezone, _not_ UTC
return date.format('YYYY-MM-DD HH:mm:ss.SSS Z');
......@@ -504,7 +504,7 @@ JSONTYPE.prototype.validate = function validate(value) {
return true;
};
JSONTYPE.prototype.$stringify = function $stringify(value, options) {
JSONTYPE.prototype._stringify = function _stringify(value, options) {
return JSON.stringify(value);
};
......@@ -566,7 +566,7 @@ BLOB.prototype.validate = function validate(value) {
};
BLOB.prototype.escape = false;
BLOB.prototype.$stringify = function $stringify(value) {
BLOB.prototype._stringify = function _stringify(value) {
if (!Buffer.isBuffer(value)) {
if (Array.isArray(value)) {
value = new Buffer(value);
......@@ -576,10 +576,10 @@ BLOB.prototype.$stringify = function $stringify(value) {
}
const hex = value.toString('hex');
return this.$hexify(hex);
return this._hexify(hex);
};
BLOB.prototype.$hexify = function $hexify(hex) {
BLOB.prototype._hexify = function _hexify(hex) {
return "X'" + hex + "'";
};
......@@ -882,7 +882,7 @@ inherits(GEOMETRY, ABSTRACT);
GEOMETRY.prototype.key = GEOMETRY.key = 'GEOMETRY';
GEOMETRY.prototype.escape = false;
GEOMETRY.prototype.$stringify = function $stringify(value) {
GEOMETRY.prototype._stringify = function _stringify(value) {
return 'GeomFromText(\'' + Wkt.convert(value) + '\')';
};
......@@ -905,7 +905,7 @@ inherits(GEOGRAPHY, ABSTRACT);
GEOGRAPHY.prototype.key = GEOGRAPHY.key = 'GEOGRAPHY';
GEOGRAPHY.prototype.escape = false;
GEOGRAPHY.prototype.$stringify = function $stringify(value) {
GEOGRAPHY.prototype._stringify = function _stringify(value) {
return 'GeomFromText(\'' + Wkt.convert(value) + '\')';
};
......
......@@ -26,7 +26,7 @@ class ConnectionManager {
if (config.pool !== false) {
config.pool =_.defaults(config.pool || {}, defaultPoolingConfig, {
validate: this.$validate.bind(this)
validate: this._validate.bind(this)
}) ;
} else {
throw new Error('Support for pool:false was removed in v4.0');
......@@ -42,7 +42,7 @@ class ConnectionManager {
_.each(dataTypes, (dataType, key) => {
if (dataType.hasOwnProperty('parse')) {
if (dataType.types[this.dialectName]) {
this.$refreshTypeParser(dataType);
this._refreshTypeParser(dataType);
} else {
throw new Error('Parse function not supported for type ' + dataType.key + ' in dialect ' + this.dialectName);
}
......@@ -77,14 +77,14 @@ class ConnectionManager {
this.pool = Pooling.Pool({
name: 'sequelize-connection',
create: (callback) => {
this.$connect(config).nodeify((err, connection) => {
this._connect(config).nodeify((err, connection) => {
debug(`pool created max/min: ${config.pool.max}/${config.pool.min} with no replication`);
callback(err, connection); // For some reason this is needed, else generic-pool things err is a connection or some shit
});
},
destroy: (connection) => {
debug(`connection destroy`);
this.$disconnect(connection);
this._disconnect(connection);
return null;
},
max: config.pool.max,
......@@ -145,14 +145,14 @@ class ConnectionManager {
create: (callback) => {
// Simple round robin config
const nextRead = reads++ % config.replication.read.length;
this.$connect(config.replication.read[nextRead]).tap(connection => {
this._connect(config.replication.read[nextRead]).tap(connection => {
connection.queryType = 'read';
}).nodeify((err, connection) => {
callback(err, connection); // For some reason this is needed, else generic-pool things err is a connection or some shit
});
},
destroy: connection => {
this.$disconnect(connection);
this._disconnect(connection);
return null;
},
validate: config.pool.validate,
......@@ -163,14 +163,14 @@ class ConnectionManager {
write: Pooling.Pool({
name: 'sequelize-connection-write',
create: callback => {
this.$connect(config.replication.write).tap(connection => {
this._connect(config.replication.write).tap(connection => {
connection.queryType = 'write';
}).nodeify((err, connection) => {
callback(err, connection); // For some reason this is needed, else generic-pool things err is a connection or some shit
});
},
destroy: connection => {
this.$disconnect(connection);
this._disconnect(connection);
return null;
},
validate: config.pool.validate,
......@@ -189,7 +189,7 @@ class ConnectionManager {
if (this.versionPromise) {
promise = this.versionPromise;
} else {
promise = this.versionPromise = this.$connect(this.config.replication.write || this.config).then(connection => {
promise = this.versionPromise = this._connect(this.config.replication.write || this.config).then(connection => {
const _options = {};
_options.transaction = {connection}; // Cheat .query to use our private connection
_options.logging = () => {};
......@@ -200,7 +200,7 @@ class ConnectionManager {
this.versionPromise = null;
this.$disconnect(connection);
this._disconnect(connection);
return null;
});
}).catch(err => {
......@@ -229,16 +229,16 @@ class ConnectionManager {
});
}
$connect(config) {
_connect(config) {
return this.sequelize.runHooks('beforeConnect', config)
.then(() => this.dialect.connectionManager.connect(config));
}
$disconnect(connection) {
_disconnect(connection) {
return this.dialect.connectionManager.disconnect(connection);
}
$validate(connection) {
_validate(connection) {
if (!this.dialect.connectionManager.validate) return Promise.resolve();
return this.dialect.connectionManager.validate(connection);
}
......
......@@ -32,14 +32,14 @@ const QueryGenerator = {
addSchema(param) {
const self = this;
if (!param.$schema) return param.tableName || param;
if (!param._schema) return param.tableName || param;
return {
tableName: param.tableName || param,
table: param.tableName || param,
name: param.name || param,
schema: param.$schema,
delimiter: param.$schemaDelimiter || '.',
schema: param._schema,
delimiter: param._schemaDelimiter || '.',
toString() {
return self.quoteTable(this);
}
......@@ -77,8 +77,8 @@ const QueryGenerator = {
const table = this.quoteTable(
this.addSchema({
tableName,
$schema: schema,
$schemaDelimiter: schemaDelimiter
_schema: schema,
_schemaDelimiter: schemaDelimiter
})
);
......@@ -633,7 +633,7 @@ const QueryGenerator = {
options = this.nameIndexes([options], options.prefix)[0];
}
options = Model.$conformIndex(options);
options = Model._conformIndex(options);
if (!this._dialect.supports.index.type) {
delete options.type;
......@@ -1109,7 +1109,7 @@ const QueryGenerator = {
}
}
attr = attr.map($attr => $attr._isSequelizeMethod ? this.handleSequelizeMethod($attr) : $attr);
attr = attr.map(attr => attr._isSequelizeMethod ? this.handleSequelizeMethod(attr) : attr);
attrAs = attr[1];
attr = attr[0];
......@@ -1233,7 +1233,7 @@ const QueryGenerator = {
let parent = include;
let child = include;
let nestedIncludes = [];
let $query;
let query;
while (parent = parent.parent) {
nestedIncludes = [_.extend({}, child, {include: nestedIncludes})];
......@@ -1244,9 +1244,9 @@ const QueryGenerator = {
const topParent = topInclude.parent;
if (topInclude.through && Object(topInclude.through.model) === topInclude.through.model) {
$query = this.selectQuery(topInclude.through.model.getTableName(), {
query = this.selectQuery(topInclude.through.model.getTableName(), {
attributes: [topInclude.through.model.primaryKeyField],
include: Model.$validateIncludedElements({
include: Model._validateIncludedElements({
model: topInclude.through.model,
include: [{
association: topInclude.association.toTarget,
......@@ -1265,7 +1265,7 @@ const QueryGenerator = {
includeIgnoreAttributes: false
}, topInclude.through.model);
} else {
$query = this.selectQuery(topInclude.model.tableName, {
query = this.selectQuery(topInclude.model.tableName, {
attributes: [topInclude.model.primaryKeyAttributes[0]],
include: topInclude.include,
where: {
......@@ -1281,7 +1281,7 @@ const QueryGenerator = {
options.where['__' + throughAs] = this.sequelize.asIs([
'(',
$query.replace(/\;$/, ''),
query.replace(/\;$/, ''),
')',
'IS NOT NULL'
].join(' '));
......@@ -2014,93 +2014,93 @@ const QueryGenerator = {
}
if (_.isPlainObject(value) && fieldType instanceof DataTypes.JSON && options.json !== false) {
const $items = [];
const items = [];
const traverse = (prop, item, path) => {
const $where = {};
let $cast;
const where = {};
let cast;
if (path[path.length - 1].indexOf('::') > -1) {
const $tmp = path[path.length - 1].split('::');
$cast = $tmp[1];
path[path.length - 1] = $tmp[0];
const tmp = path[path.length - 1].split('::');
cast = tmp[1];
path[path.length - 1] = tmp[0];
}
let $baseKey = this.quoteIdentifier(key)+'#>>\'{'+path.join(', ')+'}\'';
let baseKey = this.quoteIdentifier(key)+'#>>\'{'+path.join(', ')+'}\'';
if (options.prefix) {
if (options.prefix instanceof Utils.Literal) {
$baseKey = this.handleSequelizeMethod(options.prefix)+'.'+$baseKey;
baseKey = this.handleSequelizeMethod(options.prefix)+'.'+baseKey;
} else {
$baseKey = this.quoteTable(options.prefix)+'.'+$baseKey;
baseKey = this.quoteTable(options.prefix)+'.'+baseKey;
}
}
$baseKey = '('+$baseKey+')';
baseKey = '('+baseKey+')';
const castKey = $item => {
let key = $baseKey;
const castKey = item => {
let key = baseKey;
if (!$cast) {
if (typeof $item === 'number') {
$cast = 'double precision';
} else if ($item instanceof Date) {
$cast = 'timestamptz';
} else if (typeof $item === 'boolean') {
$cast = 'boolean';
if (!cast) {
if (typeof item === 'number') {
cast = 'double precision';
} else if (item instanceof Date) {
cast = 'timestamptz';
} else if (typeof item === 'boolean') {
cast = 'boolean';
}
}
if ($cast) {
key += '::'+$cast;
if (cast) {
key += '::'+cast;
}
return key;
};
if (_.isPlainObject(item)) {
_.forOwn(item, ($item, $prop) => {
if ($prop.indexOf('$') === 0) {
$where[$prop] = $item;
const $key = castKey($item);
_.forOwn(item, (item, prop) => {
if (prop.indexOf('$') === 0) {
where[prop] = item;
const key = castKey(item);
$items.push(this.whereItemQuery(new Utils.Literal($key), $where/*, _.pick(options, 'prefix')*/));
items.push(this.whereItemQuery(new Utils.Literal(key), where/*, _.pick(options, 'prefix')*/));
} else {
traverse($prop, $item, path.concat([$prop]));
traverse(prop, item, path.concat([prop]));
}
});
} else {
$where.$eq = item;
const $key = castKey(item);
where.$eq = item;
const key = castKey(item);
$items.push(this.whereItemQuery(new Utils.Literal($key), $where/*, _.pick(options, 'prefix')*/));
items.push(this.whereItemQuery(new Utils.Literal(key), where/*, _.pick(options, 'prefix')*/));
}
};
_.forOwn(value, (item, prop) => {
if (prop.indexOf('$') === 0) {
const $where = {};
$where[prop] = item;
$items.push(this.whereItemQuery(key, $where, _.assign({}, options, {json: false})));
const where = {};
where[prop] = item;
items.push(this.whereItemQuery(key, where, _.assign({}, options, {json: false})));
return;
}
traverse(prop, item, [prop]);
});
const result = $items.join(' AND ');
return $items.length > 1 ? '('+result+')' : result;
const result = items.join(' AND ');
return items.length > 1 ? '('+result+')' : result;
}
// If multiple keys we combine the different logic conditions
if (_.isPlainObject(value) && Object.keys(value).length > 1) {
const $items = [];
const items = [];
_.forOwn(value, (item, logic) => {
const $where = {};
$where[logic] = item;
$items.push(this.whereItemQuery(key, $where, options));
const where = {};
where[logic] = item;
items.push(this.whereItemQuery(key, where, options));
});
return '('+$items.join(' AND ')+')';
return '('+items.join(' AND ')+')';
}
// Do [] to $in/$notIn normalization
......
......@@ -272,7 +272,7 @@ class AbstractQuery {
});
// Queries with include
} else if (this.options.hasJoin === true) {
results = AbstractQuery.$groupJoinData(results, {
results = AbstractQuery._groupJoinData(results, {
model: this.model,
includeMap: this.options.includeMap,
includeNames: this.options.includeNames
......@@ -354,7 +354,7 @@ class AbstractQuery {
* }
* ]
*/
static $groupJoinData(rows, includeOptions, options) {
static _groupJoinData(rows, includeOptions, options) {
/*
* Assumptions
......
......@@ -26,11 +26,11 @@ class ConnectionManager extends AbstractConnectionManager {
}
// Expose this as a method so that the parsing may be updated when the user has added additional, custom types
$refreshTypeParser(dataType) {
_refreshTypeParser(dataType) {
parserStore.refresh(dataType);
}
$clearTypeParser() {
_clearTypeParser() {
parserStore.clear();
}
......
......@@ -42,7 +42,7 @@ module.exports = BaseTypes => {
return 'VARBINARY(MAX)';
};
BLOB.prototype.$hexify = function $hexify(hex) {
BLOB.prototype._hexify = function _hexify(hex) {
return '0x' + hex;
};
......@@ -61,9 +61,9 @@ module.exports = BaseTypes => {
};
STRING.prototype.escape = false;
STRING.prototype.$stringify = function $stringify(value, options) {
STRING.prototype._stringify = function _stringify(value, options) {
if (this._binary) {
return BLOB.prototype.$stringify(value);
return BLOB.prototype._stringify(value);
} else {
return options.escape(value);
}
......@@ -128,8 +128,8 @@ module.exports = BaseTypes => {
return 'DATETIME2';
};
DATE.prototype.$stringify = function $stringify(date, options) {
date = this.$applyTimezone(date, options);
DATE.prototype._stringify = function _stringify(date, options) {
date = this._applyTimezone(date, options);
// mssql not allow +timezone datetime format
return date.format('YYYY-MM-DD HH:mm:ss.SSS');
......
......@@ -31,17 +31,17 @@ class ConnectionManager extends AbstractConnectionManager {
}
// Expose this as a method so that the parsing may be updated when the user has added additional, custom types
$refreshTypeParser(dataType) {
_refreshTypeParser(dataType) {
for (const type of dataType.types.mysql) {
parserMap.set(type, dataType.parse);
}
}
$clearTypeParser() {
_clearTypeParser() {
parserMap.clear();
}
static $typecast(field, next) {
static _typecast(field, next) {
if (parserMap.has(field.type)) {
return parserMap.get(field.type)(field, this.sequelize.options);
}
......@@ -58,7 +58,7 @@ class ConnectionManager extends AbstractConnectionManager {
password: config.password,
database: config.database,
timezone: this.sequelize.options.timezone,
typeCast: ConnectionManager.$typecast.bind(this),
typeCast: ConnectionManager._typecast.bind(this),
bigNumberStrings: false,
supportBigNumbers: true
};
......
......@@ -35,8 +35,8 @@ module.exports = BaseTypes => {
return 'DATETIME' + (this._length ? '(' + this._length + ')' : '');
};
DATE.prototype.$stringify = function $stringify(date, options) {
date = BaseTypes.DATE.prototype.$applyTimezone(date, options);
DATE.prototype._stringify = function _stringify(date, options) {
date = BaseTypes.DATE.prototype._applyTimezone(date, options);
// Fractional DATETIMEs only supported on MySQL 5.6.4+
if (this._length) {
return date.format('YYYY-MM-DD HH:mm:ss.SSS');
......
......@@ -34,7 +34,7 @@ class ConnectionManager extends AbstractConnectionManager {
}
// Expose this as a method so that the parsing may be updated when the user has added additional, custom types
$refreshTypeParser(dataType) {
_refreshTypeParser(dataType) {
if (dataType.types.postgres.oids) {
for (const oid of dataType.types.postgres.oids) {
......@@ -165,7 +165,7 @@ class ConnectionManager extends AbstractConnectionManager {
type.types.postgres.oids.push(row.oid);
type.types.postgres.array_oids.push(row.typarray);
this.$refreshTypeParser(type);
this._refreshTypeParser(type);
})
.on('end', () => resolve());
});
......
......@@ -263,7 +263,7 @@ module.exports = BaseTypes => {
return 'BYTEA';
};
BLOB.prototype.$hexify = function $hexify(hex) {
BLOB.prototype._hexify = function _hexify(hex) {
// bytea hex format http://www.postgresql.org/docs/current/static/datatype-binary.html
return "E'\\\\x" + hex + "'";
};
......@@ -305,7 +305,7 @@ module.exports = BaseTypes => {
return wkx.Geometry.parse(b).toGeoJSON();
};
GEOMETRY.prototype.$stringify = function $stringify(value) {
GEOMETRY.prototype._stringify = function _stringify(value) {
return 'ST_GeomFromGeoJSON(\'' + JSON.stringify(value) + '\')';
};
......@@ -341,7 +341,7 @@ module.exports = BaseTypes => {
return wkx.Geometry.parse(b).toGeoJSON();
};
GEOGRAPHY.prototype.$stringify = function $stringify(value) {
GEOGRAPHY.prototype._stringify = function _stringify(value) {
return 'ST_GeomFromGeoJSON(\'' + JSON.stringify(value) + '\')';
};
......@@ -366,7 +366,7 @@ module.exports = BaseTypes => {
};
HSTORE.prototype.escape = false;
HSTORE.prototype.$stringify = function $stringify(value) {
HSTORE.prototype._stringify = function _stringify(value) {
if (!hstore) {
// All datatype files are loaded at import - make sure we don't load the hstore parser before a hstore is instantiated
hstore = require('./hstore');
......@@ -408,7 +408,7 @@ module.exports = BaseTypes => {
};
RANGE.prototype.escape = false;
RANGE.prototype.$stringify = function $stringify(values, options) {
RANGE.prototype._stringify = function _stringify(values, options) {
if (!Array.isArray(values)) {
return "'" + this.options.subtype.stringify(values, options) + "'::" +
this.toCastType();
......@@ -433,7 +433,7 @@ module.exports = BaseTypes => {
};
BaseTypes.ARRAY.prototype.escape = false;
BaseTypes.ARRAY.prototype.$stringify = function $stringify(values, options) {
BaseTypes.ARRAY.prototype._stringify = function _stringify(values, options) {
let str = 'ARRAY[' + values.map(value => {
if (this.type && this.type.stringify) {
value = this.type.stringify(value, options);
......
......@@ -33,11 +33,11 @@ class ConnectionManager extends AbstractConnectionManager {
}
// Expose this as a method so that the parsing may be updated when the user has added additional, custom types
$refreshTypeParser(dataType) {
_refreshTypeParser(dataType) {
parserStore.refresh(dataType);
}
$clearTypeParser() {
_clearTypeParser() {
parserStore.clear();
}
......
......@@ -237,8 +237,8 @@ const QueryGenerator = {
describeTableQuery(tableName, schema, schemaDelimiter) {
const table = {
$schema: schema,
$schemaDelimiter: schemaDelimiter,
_schema: schema,
_schemaDelimiter: schemaDelimiter,
tableName
};
return `PRAGMA TABLE_INFO(${this.quoteTable(this.addSchema(table))});`;
......
......@@ -53,7 +53,7 @@ class Query extends AbstractQuery {
return [sql, bindParam];
}
$collectModels(include, prefix) {
_collectModels(include, prefix) {
const ret = {};
if (include) {
......@@ -67,7 +67,7 @@ class Query extends AbstractQuery {
ret[key] = _include.model;
if (_include.include) {
_.merge(ret, this.$collectModels(_include.include, key));
_.merge(ret, this._collectModels(_include.include, key));
}
}
}
......@@ -136,7 +136,7 @@ class Query extends AbstractQuery {
} else if (query.isSelectQuery()) {
if (!query.options.raw) {
// This is a map of prefix strings to models, e.g. user.projects -> Project model
const prefixes = query.$collectModels(query.options.include);
const prefixes = query._collectModels(query.options.include);
results = results.map(result => {
return _.mapValues(result, (value, name) => {
......
......@@ -137,7 +137,7 @@ exports.DatabaseError = DatabaseError;
* @extends DatabaseError
* @constructor
*/
class TimeoutError extends BaseError {
class TimeoutError extends DatabaseError {
constructor(parent) {
super(parent);
this.name = 'SequelizeTimeoutError';
......
......@@ -133,7 +133,7 @@ class InstanceValidator {
*/
_customValidators() {
const validators = [];
Utils._.each(this.modelInstance.$modelOptions.validate, (validator, validatorType) => {
Utils._.each(this.modelInstance._modelOptions.validate, (validator, validatorType) => {
if (this.options.skip.indexOf(validatorType) >= 0) {
return;
}
......
......@@ -16,10 +16,10 @@ class ModelManager {
return model;
}
removeModel(model) {
this.models = this.models.filter($model => $model.name !== model.name);
removeModel(modelToRemove) {
this.models = this.models.filter(model => model.name !== modelToRemove.name);
delete this.sequelize.models[model.name];
delete this.sequelize.models[modelToRemove.name];
}
getModel(against, options) {
......
......@@ -135,10 +135,10 @@ class QueryInterface {
}
if (!tableName.schema &&
(options.schema || (!!model && model.$schema))) {
(options.schema || (!!model && model._schema))) {
tableName = this.QueryGenerator.addSchema({
tableName,
$schema: (!!model && model.$schema) || options.schema
_schema: (!!model && model._schema) || options.schema
});
}
......@@ -153,10 +153,10 @@ class QueryInterface {
});
} else {
if (!tableName.schema &&
(options.schema || (!!model && model.$schema))) {
(options.schema || (!!model && model._schema))) {
tableName = this.QueryGenerator.addSchema({
tableName,
$schema: (!!model && model.$schema) || options.schema
_schema: (!!model && model._schema) || options.schema
});
}
......@@ -541,7 +541,7 @@ class QueryInterface {
update(instance, tableName, values, identifier, options) {
options = _.clone(options || {});
options.hasTrigger = !!(instance && instance.$modelOptions && instance.$modelOptions.hasTrigger);
options.hasTrigger = !!(instance && instance._modelOptions && instance._modelOptions.hasTrigger);
const sql = this.QueryGenerator.updateQuery(tableName, values, identifier, options, instance.constructor.rawAttributes);
......@@ -650,7 +650,7 @@ class QueryInterface {
if (options.schema) {
tableName = this.QueryGenerator.addSchema({
tableName,
$schema: options.schema
_schema: options.schema
});
}
......
......@@ -248,13 +248,13 @@ class Sequelize {
this.importCache = {};
this.test = {
$trackRunningQueries: false,
$runningQueries: 0,
_trackRunningQueries: false,
_runningQueries: 0,
trackRunningQueries() {
this.$trackRunningQueries = true;
this._trackRunningQueries = true;
},
verifyNoRunningQueries() {
if (this.$runningQueries > 0) throw new Error('Expected 0 running queries. '+this.$runningQueries+' queries still running');
if (this._runningQueries > 0) throw new Error('Expected 0 running queries. '+this._runningQueries+' queries still running');
}
};
......@@ -509,7 +509,7 @@ class Sequelize {
* @param {Boolean} [options.nest=false] If true, transforms objects with `.` separated property names into nested objects using [dottie.js](https://github.com/mickhansen/dottie.js). For example { 'user.username': 'john' } becomes { user: { username: 'john' }}. When `nest` is true, the query type is assumed to be `'SELECT'`, unless otherwise specified
* @param {Boolean} [options.plain=false] Sets the query type to `SELECT` and return a single row
* @param {Object|Array} [options.replacements] Either an object of named parameter replacements in the format `:param` or an array of unnamed replacements to replace `?` in your SQL.
* @param {Object|Array} [options.bind] Either an object of named bind parameter in the format `$param` or an array of unnamed bind parameter to replace `$1, $2, ...` in your SQL.
* @param {Object|Array} [options.bind] Either an object of named bind parameter in the format `_param` or an array of unnamed bind parameter to replace `$1, $2, ...` in your SQL.
* @param {Boolean} [options.useMaster=false] Force the query to use the write pool, regardless of the query type.
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @param {Instance} [options.instance] A sequelize instance used to build the return instance
......@@ -612,8 +612,8 @@ class Sequelize {
return Promise.reject(error);
}
if (this.test.$trackRunningQueries) {
this.test.$runningQueries++;
if (this.test._trackRunningQueries) {
this.test._runningQueries++;
}
//if dialect doesn't support search_path or dialect option
......@@ -638,8 +638,8 @@ class Sequelize {
}
}), Utils._.extend(this.options.retry, options.retry || {}));
}).finally(() => {
if (this.test.$trackRunningQueries) {
this.test.$runningQueries--;
if (this.test._trackRunningQueries) {
this.test._runningQueries--;
}
});
}
......
......@@ -56,7 +56,7 @@ class Transaction {
return Utils.Promise.reject(new Error('Transaction cannot be committed because it has been finished with state: ' + this.finished));
}
this.$clearCls();
this._clearCls();
return this
.sequelize
......@@ -82,7 +82,7 @@ class Transaction {
return Utils.Promise.reject(new Error('Transaction cannot be rolled back because it has been finished with state: ' + this.finished));
}
this.$clearCls();
this._clearCls();
return this
.sequelize
......@@ -154,7 +154,7 @@ class Transaction {
return res;
}
$clearCls () {
_clearCls () {
const cls = this.sequelize.constructor.cls;
if (cls) {
......
......@@ -36,7 +36,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
});
break;
default:
this.sequelize.connectionManager.$clearTypeParser();
this.sequelize.connectionManager._clearTypeParser();
}
this.sequelize.connectionManager.refreshTypeParser(DataTypes[dialect]); // Reload custom parsers
......@@ -49,7 +49,7 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
var stringify = Sequelize.DATE.prototype.stringify = sinon.spy(function (value, options) {
if (!moment.isMoment(value)) {
value = this.$applyTimezone(value, options);
value = this._applyTimezone(value, options);
}
return value.format('YYYY-MM-DD HH:mm:ss Z');
});
......
......@@ -82,8 +82,8 @@ describe('Connction Manager', function() {
});
});
var connectStub = sandbox.stub(connectionManager, '$connect').returns(resolvedPromise);
sandbox.stub(connectionManager, '$disconnect').returns(resolvedPromise);
var connectStub = sandbox.stub(connectionManager, '_connect').returns(resolvedPromise);
sandbox.stub(connectionManager, '_disconnect').returns(resolvedPromise);
sandbox.stub(sequelize, 'databaseVersion').returns(resolvedPromise);
connectionManager.initPools();
......@@ -128,8 +128,8 @@ describe('Connction Manager', function() {
});
});
var connectStub = sandbox.stub(connectionManager, '$connect').returns(resolvedPromise);
sandbox.stub(connectionManager, '$disconnect').returns(resolvedPromise);
var connectStub = sandbox.stub(connectionManager, '_connect').returns(resolvedPromise);
sandbox.stub(connectionManager, '_disconnect').returns(resolvedPromise);
sandbox.stub(sequelize, 'databaseVersion').returns(resolvedPromise);
connectionManager.initPools();
......
......@@ -532,12 +532,12 @@ describe(Support.getTestDialectTeaser('Instance'), function() {
return Book.findOne({
where: { id: book.id }
}).then(function(leBook) {
var oldOptions = leBook.$options;
var oldOptions = leBook._options;
return leBook.reload({
include: [Page]
}).then(function(leBook) {
expect(oldOptions).not.to.equal(leBook.$options);
expect(leBook.$options.include.length).to.equal(1);
expect(oldOptions).not.to.equal(leBook._options);
expect(leBook._options.include.length).to.equal(1);
expect(leBook.Pages.length).to.equal(1);
expect(leBook.get({plain: true}).Pages.length).to.equal(1);
});
......
......@@ -10,7 +10,7 @@ var chai = require('chai')
, Promise = Sequelize.Promise;
describe('connection manager', function () {
describe('$connect', function () {
describe('_connect', function () {
beforeEach(function () {
this.sinon = sinon.sandbox.create();
......@@ -35,7 +35,7 @@ describe('connection manager', function () {
var config = {};
return expect(connectionManager.$connect(config)).to.eventually.equal(connection).then(function () {
return expect(connectionManager._connect(config)).to.eventually.equal(connection).then(function () {
expect(this.dialect.connectionManager.connect).to.have.been.calledWith(config);
}.bind(this));
});
......@@ -52,7 +52,7 @@ describe('connection manager', function () {
var connectionManager = new ConnectionManager(this.dialect, this.sequelize);
return connectionManager.$connect({}).then(function () {
return connectionManager._connect({}).then(function () {
expect(this.dialect.connectionManager.connect).to.have.been.calledWith({
username: username,
password: password
......
......@@ -33,10 +33,10 @@ describe('[MSSQL] Connection Manager', function () {
, config);
});
it('connectionManager.$connect() Does not delete `domain` from config.dialectOptions',
it('connectionManager._connect() Does not delete `domain` from config.dialectOptions',
function () {
expect(config.dialectOptions.domain).to.equal('TEST.COM');
instance.dialect.connectionManager.$connect(config);
instance.dialect.connectionManager._connect(config);
expect(config.dialectOptions.domain).to.equal('TEST.COM');
});
});
......@@ -17,7 +17,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('can expand nested self-reference', function () {
var options = { include: [{ all: true, nested: true }] };
current.Model.$expandIncludeAll.call(Referral, options);
current.Model._expandIncludeAll.call(Referral, options);
expect(options.include).to.deep.equal([
{ model: Referral }
......@@ -25,7 +25,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
describe('$validateIncludedElements', function () {
describe('_validateIncludedElements', function () {
beforeEach(function () {
this.User = this.sequelize.define('User');
this.Task = this.sequelize.define('Task', {
......@@ -49,7 +49,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
describe('attributes', function () {
it('should not inject the aliassed PK again, if its already there', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{
......@@ -61,7 +61,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect(options.include[0].attributes).to.deep.equal([['field_id', 'id'], 'name']);
options = Sequelize.Model.$validateIncludedElements(options);
options = Sequelize.Model._validateIncludedElements(options);
// Calling validate again shouldn't add the pk again
expect(options.include[0].attributes).to.deep.equal([['field_id', 'id'], 'name']);
......@@ -69,7 +69,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
describe('include / exclude', function () {
it('allows me to include additional attributes', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{
......@@ -92,7 +92,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('allows me to exclude attributes', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{
......@@ -113,7 +113,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('include takes precendence over exclude', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{
......@@ -174,7 +174,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('adds the default scope to where', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [{ model: this.Project }]
});
......@@ -183,7 +183,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('adds the where from a scoped model', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [{ model: this.Project.scope('that') }]
});
......@@ -193,7 +193,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('adds the attributes from a scoped model', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [{ model: this.Project.scope('attr') }]
});
......@@ -202,7 +202,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('merges where with the where from a scoped model', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [{ where: { active: false }, model: this.Project.scope('that') }]
});
......@@ -211,7 +211,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('add the where from a scoped associated model', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [{ model: this.Project, as: 'thisProject' }]
});
......@@ -220,7 +220,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('handles a scope with an aliased column (.field)', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [{ model: this.Project.scope('foobar') }]
});
......@@ -231,7 +231,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
describe('duplicating', function () {
it('should tag a hasMany association as duplicating: true if undefined', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
this.User.Tasks
......@@ -242,7 +242,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should respect include.duplicating for a hasMany', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Tasks, duplicating: false}
......@@ -255,7 +255,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
describe('subQuery', function () {
it('should be true if theres a duplicating association', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Tasks}
......@@ -267,7 +267,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should be false if theres a duplicating association but no limit', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Tasks}
......@@ -279,7 +279,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should be true if theres a nested duplicating association', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Company, include: [
......@@ -293,7 +293,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should be false if theres a nested duplicating association but no limit', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Company, include: [
......@@ -307,7 +307,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should tag a required hasMany association', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Tasks, required: true}
......@@ -321,7 +321,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should not tag a required hasMany association with duplicating false', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Tasks, required: true, duplicating: false}
......@@ -335,7 +335,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should tag a hasMany association with where', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Tasks, where: {title: Math.random().toString()}}
......@@ -349,7 +349,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should not tag a hasMany association with where and duplicating false', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Tasks, where: {title: Math.random().toString()}, duplicating: false}
......@@ -363,7 +363,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should tag a required belongsTo alongside a duplicating association', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Company, required: true},
......@@ -377,7 +377,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should not tag a required belongsTo alongside a duplicating association with duplicating false', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Company, required: true},
......@@ -391,7 +391,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should tag a belongsTo association with where alongside a duplicating association', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Company, where: {name: Math.random().toString()}},
......@@ -405,7 +405,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should tag a required belongsTo association alongside a duplicating association with a nested belongsTo', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Company, required: true, include: [
......@@ -423,7 +423,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should tag a belongsTo association with where alongside a duplicating association with duplicating false', function () {
var options = Sequelize.Model.$validateIncludedElements({
var options = Sequelize.Model._validateIncludedElements({
model: this.User,
include: [
{association: this.User.Company, where: {name: Math.random().toString()}},
......
......@@ -16,49 +16,49 @@ describe(Support.getTestDialectTeaser('Model') + 'Schemas', function() {
describe('schema', function() {
it('should work with no default schema', function() {
expect(Project.$schema).to.be.null;
expect(Project._schema).to.be.null;
});
it('should apply default schema from define', function() {
expect(Company.$schema).to.equal('default');
expect(Company._schema).to.equal('default');
});
it('should be able to override the default schema', function() {
expect(Company.schema('newSchema').$schema).to.equal('newSchema');
expect(Company.schema('newSchema')._schema).to.equal('newSchema');
});
it('should be able nullify schema', function() {
expect(Company.schema(null).$schema).to.be.null;
expect(Company.schema(null)._schema).to.be.null;
});
it('should support multiple, coexistent schema models', function() {
var schema1 = Company.schema('schema1')
, schema2 = Company.schema('schema1');
expect(schema1.$schema).to.equal('schema1');
expect(schema2.$schema).to.equal('schema1');
expect(schema1._schema).to.equal('schema1');
expect(schema2._schema).to.equal('schema1');
});
});
describe('schema delimiter', function() {
it('should work with no default schema delimiter', function() {
expect(Project.$schemaDelimiter).to.equal('');
expect(Project._schemaDelimiter).to.equal('');
});
it('should apply default schema delimiter from define', function() {
expect(Company.$schemaDelimiter).to.equal('&');
expect(Company._schemaDelimiter).to.equal('&');
});
it('should be able to override the default schema delimiter', function() {
expect(Company.schema(Company.$schema,'^').$schemaDelimiter).to.equal('^');
expect(Company.schema(Company._schema,'^')._schemaDelimiter).to.equal('^');
});
it('should support multiple, coexistent schema delimiter models', function() {
var schema1 = Company.schema(Company.$schema,'$')
, schema2 = Company.schema(Company.$schema,'#');
var schema1 = Company.schema(Company._schema,'$')
, schema2 = Company.schema(Company._schema,'#');
expect(schema1.$schemaDelimiter).to.equal('$');
expect(schema2.$schemaDelimiter).to.equal('#');
expect(schema1._schemaDelimiter).to.equal('$');
expect(schema2._schemaDelimiter).to.equal('#');
});
});
}
......
......@@ -91,7 +91,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should be able to exclude in defaultScope #4735', function () {
expect(User.$scope.attributes).to.deep.equal([
expect(User._scope.attributes).to.deep.equal([
'id',
'name',
'createdAt',
......@@ -100,7 +100,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should be able to exclude in a scope #4925', function () {
expect(User.scope('aScope').$scope.attributes).to.deep.equal([
expect(User.scope('aScope')._scope.attributes).to.deep.equal([
'id',
'name',
'createdAt',
......@@ -112,25 +112,25 @@ describe(Support.getTestDialectTeaser('Model'), function() {
it('defaultScope should be an empty object if not overridden', function () {
var Foo = current.define('foo', {}, {});
expect(Foo.scope('defaultScope').$scope).to.deep.equal({});
expect(Foo.scope('defaultScope')._scope).to.deep.equal({});
});
it('should apply default scope', function () {
expect(Company.$scope).to.deep.equal({
expect(Company._scope).to.deep.equal({
include: [{ model: Project }],
where: { active: true }
});
});
it('should be able to unscope', function () {
expect(Company.scope(null).$scope).to.be.empty;
expect(Company.unscoped().$scope).to.be.empty;
expect(Company.scope(null)._scope).to.be.empty;
expect(Company.unscoped()._scope).to.be.empty;
// Yes, being unscoped is also a scope - this prevents inject defaultScope, when including a scoped model, see #4663
expect(Company.unscoped().scoped).to.be.ok;
});
it('should be able to merge scopes', function() {
expect(Company.scope('somethingTrue', 'somethingFalse').$scope).to.deep.equal({
expect(Company.scope('somethingTrue', 'somethingFalse')._scope).to.deep.equal({
where: {
something: false,
somethingElse: 42
......@@ -143,18 +143,18 @@ describe(Support.getTestDialectTeaser('Model'), function() {
var scoped1 = Company.scope('somethingTrue')
, scoped2 = Company.scope('somethingFalse');
expect(scoped1.$scope).to.deep.equal(scopes.somethingTrue);
expect(scoped2.$scope).to.deep.equal(scopes.somethingFalse);
expect(scoped1._scope).to.deep.equal(scopes.somethingTrue);
expect(scoped2._scope).to.deep.equal(scopes.somethingFalse);
});
it('should work with function scopes', function () {
expect(Company.scope({method: ['actualValue', 11]}).$scope).to.deep.equal({
expect(Company.scope({method: ['actualValue', 11]})._scope).to.deep.equal({
where: {
other_value: 11
}
});
expect(Company.scope('noArgs').$scope).to.deep.equal({
expect(Company.scope('noArgs')._scope).to.deep.equal({
where: {
other_value: 7
}
......@@ -162,7 +162,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should be able to merge two scoped includes', function () {
expect(Company.scope('users', 'projects').$scope).to.deep.equal({
expect(Company.scope('users', 'projects')._scope).to.deep.equal({
include: [
{ model: User },
{ model: Project }
......@@ -171,11 +171,11 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should be able to override the default scope', function() {
expect(Company.scope('somethingTrue').$scope).to.deep.equal(scopes.somethingTrue);
expect(Company.scope('somethingTrue')._scope).to.deep.equal(scopes.somethingTrue);
});
it('should be able to combine default with another scope', function () {
expect(Company.scope(['defaultScope', {method: ['actualValue', 11]}]).$scope).to.deep.equal({
expect(Company.scope(['defaultScope', {method: ['actualValue', 11]}])._scope).to.deep.equal({
include: [{ model: Project }],
where: {
active: true,
......@@ -185,13 +185,13 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
it('should be able to use raw queries', function () {
expect(Company.scope([{method: ['complexFunction', 'qux']}]).$scope).to.deep.equal({
expect(Company.scope([{method: ['complexFunction', 'qux']}])._scope).to.deep.equal({
where: [ 'qux IN (SELECT foobar FROM some_sql_function(foo.bar))' ]
});
});
it('should override the default scope', function () {
expect(Company.scope(['defaultScope', {method: ['complexFunction', 'qux']}]).$scope).to.deep.equal({
expect(Company.scope(['defaultScope', {method: ['complexFunction', 'qux']}])._scope).to.deep.equal({
include: [{ model: Project }],
where: [ 'qux IN (SELECT foobar FROM some_sql_function(foo.bar))' ]
});
......@@ -225,7 +225,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
include: [Project]
});
expect(Company.scope('newScope').$scope).to.deep.equal({
expect(Company.scope('newScope')._scope).to.deep.equal({
where: { this: 'that' },
include: [{ model: Project }]
});
......@@ -244,7 +244,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}
}, { override: true });
expect(Company.scope('somethingTrue').$scope).to.deep.equal({
expect(Company.scope('somethingTrue')._scope).to.deep.equal({
where: { something: false },
});
});
......@@ -260,7 +260,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
include: [Project]
}, { override: true });
expect(Company.$scope).to.deep.equal({
expect(Company._scope).to.deep.equal({
include: [{ model: Project }]
});
});
......@@ -273,14 +273,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}
});
expect(Company.scope('newIncludeScope').$scope).to.deep.equal({
expect(Company.scope('newIncludeScope')._scope).to.deep.equal({
attributes: ['id', 'updatedAt', 'foobar']
});
});
});
describe('$injectScope', function () {
describe('_injectScope', function () {
it('should be able to merge scope and where', function () {
var scope = {
where: {
......@@ -298,8 +298,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
limit: 9
};
current.Model.$injectScope.call({
$scope: scope
current.Model._injectScope.call({
_scope: scope
}, options);
expect(options).to.deep.equal({
......@@ -322,8 +322,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
var options = {};
current.Model.$injectScope.call({
$scope: scope
current.Model._injectScope.call({
_scope: scope
}, options);
expect(options.include).to.have.length(1);
......@@ -339,8 +339,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
include: [{ model: Project, where: { something: true }}]
};
current.Model.$injectScope.call({
$scope: scope
current.Model._injectScope.call({
_scope: scope
}, options);
expect(options.include).to.have.length(1);
......@@ -356,8 +356,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
include: [{model: User, as: 'otherUser'}]
};
current.Model.$injectScope.call({
$scope: scope
current.Model._injectScope.call({
_scope: scope
}, options);
expect(options.include).to.have.length(2);
......@@ -378,8 +378,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]
};
current.Model.$injectScope.call({
$scope: scope
current.Model._injectScope.call({
_scope: scope
}, options);
expect(options.include).to.have.length(2);
......@@ -401,8 +401,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]
};
current.Model.$injectScope.call({
$scope: scope
current.Model._injectScope.call({
_scope: scope
}, options);
expect(options.include).to.have.length(2);
......@@ -424,8 +424,8 @@ describe(Support.getTestDialectTeaser('Model'), function() {
]
};
current.Model.$injectScope.call({
$scope: scope
current.Model._injectScope.call({
_scope: scope
}, options);
expect(options.include).to.have.length(2);
......
......@@ -29,7 +29,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
});
expectsql(sql.addIndexQuery(sql.quoteTable(sql.addSchema({
$schema: 'schema',
_schema: 'schema',
tableName: 'table'
})), ['column1', 'column2'], {}), {
default: 'CREATE INDEX [schema_table_column1_column2] ON [schema].[table] ([column1], [column2])'
......
......@@ -79,7 +79,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: false,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
model: User,
include: [
User.Company
......@@ -92,7 +92,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: false,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
model: User,
include: [
{association: User.Company, where: {public: true}, or: true}
......@@ -107,7 +107,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: true,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -122,7 +122,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
model: User,
subQuery: true,
groupedLimit: {},
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -136,7 +136,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: true,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -154,7 +154,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: true,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -170,7 +170,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: true,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -188,7 +188,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: true,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -205,7 +205,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: true,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -223,7 +223,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: false,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
model: User,
include: [
User.Tasks
......@@ -236,7 +236,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: true,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -251,7 +251,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: true,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
limit: 3,
model: User,
include: [
......@@ -266,7 +266,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: false,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
model: User,
include: [
{association: User.Tasks, on: {
......@@ -284,7 +284,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
testsql({
model: User,
subQuery: false,
include: Sequelize.Model.$validateIncludedElements({
include: Sequelize.Model._validateIncludedElements({
model: User,
include: [
{association: User.Tasks, on: {'user_id': {$col: 'User.alternative_id'}}}
......
......@@ -120,7 +120,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
Post.Comments = Post.hasMany(Comment, {foreignKey: 'postId', as: 'COMMENTS'});
var include = Model.$validateIncludedElements({
var include = Model._validateIncludedElements({
include: [{
attributes: ['title'],
association: User.Posts
......@@ -158,7 +158,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
+') AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id];'
});
var nestedInclude = Model.$validateIncludedElements({
var nestedInclude = Model._validateIncludedElements({
include: [{
attributes: ['title'],
association: User.Posts,
......@@ -220,7 +220,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
expectsql(sql.selectQuery('User', {
attributes: ['name', 'age'],
include: Model.$validateIncludedElements({
include: Model._validateIncludedElements({
include: [{
attributes: ['title'],
association: User.Posts
......@@ -277,7 +277,7 @@ suite(Support.getTestDialectTeaser('SQL'), function() {
expectsql(sql.selectQuery('User', {
attributes: ['name', 'age'],
include: Model.$validateIncludedElements({
include: Model._validateIncludedElements({
include: [{
attributes: ['title'],
association: User.Posts
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!