Socket
Socket
Sign inDemoInstall

objection

Package Overview
Dependencies
5
Maintainers
2
Versions
200
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.0-rc.4 to 0.6.0-rc.5

7

lib/model/Model.js

@@ -882,2 +882,7 @@ 'use strict';

/**
* @type {object}
*/
/**
* @private

@@ -897,3 +902,3 @@ */

return Model;
}(_ModelBase3.default), _class2.QueryBuilder = _QueryBuilder2.default, _class2.RelatedQueryBuilder = _QueryBuilder2.default, _class2.HasOneRelation = _HasOneRelation2.default, _class2.HasManyRelation = _HasManyRelation2.default, _class2.ManyToManyRelation = _ManyToManyRelation2.default, _class2.BelongsToOneRelation = _BelongsToOneRelation2.default, _class2.JoinEagerAlgorithm = JoinEagerAlgorithm, _class2.WhereInEagerAlgorithm = WhereInEagerAlgorithm, _class2.tableName = null, _class2.idColumn = 'id', _class2.uidProp = '#id', _class2.uidRefProp = '#ref', _class2.dbRefProp = '#dbRef', _class2.propRefRegex = /#ref{([^\.]+)\.([^}]+)}/g, _class2.jsonAttributes = null, _class2.relationMappings = null, _class2.modelPaths = [], _class2.pickJsonSchemaProperties = true, _class2.defaultEagerAlgorithm = WhereInEagerAlgorithm, _class2.$$knex = null, _temp), (_applyDecoratedDescriptor(_class, 'OneToOneRelation', [_dec], (0, _getOwnPropertyDescriptor2.default)(_class, 'OneToOneRelation'), _class), _applyDecoratedDescriptor(_class, 'OneToManyRelation', [_dec2], (0, _getOwnPropertyDescriptor2.default)(_class, 'OneToManyRelation'), _class), _applyDecoratedDescriptor(_class, 'getIdColumnArray', [_memoize2.default], (0, _getOwnPropertyDescriptor2.default)(_class, 'getIdColumnArray'), _class), _applyDecoratedDescriptor(_class, 'getFullIdColumn', [_memoize2.default], (0, _getOwnPropertyDescriptor2.default)(_class, 'getFullIdColumn'), _class), _applyDecoratedDescriptor(_class, 'getIdPropertyArray', [_memoize2.default], (0, _getOwnPropertyDescriptor2.default)(_class, 'getIdPropertyArray'), _class), _applyDecoratedDescriptor(_class, 'getIdProperty', [_memoize2.default], (0, _getOwnPropertyDescriptor2.default)(_class, 'getIdProperty'), _class), _applyDecoratedDescriptor(_class, 'relations', [_dec3], (0, _getOwnPropertyDescriptor2.default)(_class, 'relations'), _class), _applyDecoratedDescriptor(_class, 'relations', [_dec4], (0, _getOwnPropertyDescriptor2.default)(_class, 'relations'), _class)), _class));
}(_ModelBase3.default), _class2.QueryBuilder = _QueryBuilder2.default, _class2.RelatedQueryBuilder = _QueryBuilder2.default, _class2.HasOneRelation = _HasOneRelation2.default, _class2.HasManyRelation = _HasManyRelation2.default, _class2.ManyToManyRelation = _ManyToManyRelation2.default, _class2.BelongsToOneRelation = _BelongsToOneRelation2.default, _class2.JoinEagerAlgorithm = JoinEagerAlgorithm, _class2.WhereInEagerAlgorithm = WhereInEagerAlgorithm, _class2.tableName = null, _class2.idColumn = 'id', _class2.uidProp = '#id', _class2.uidRefProp = '#ref', _class2.dbRefProp = '#dbRef', _class2.propRefRegex = /#ref{([^\.]+)\.([^}]+)}/g, _class2.jsonAttributes = null, _class2.relationMappings = null, _class2.modelPaths = [], _class2.pickJsonSchemaProperties = true, _class2.defaultEagerAlgorithm = WhereInEagerAlgorithm, _class2.defaultEagerOptions = null, _class2.$$knex = null, _temp), (_applyDecoratedDescriptor(_class, 'OneToOneRelation', [_dec], (0, _getOwnPropertyDescriptor2.default)(_class, 'OneToOneRelation'), _class), _applyDecoratedDescriptor(_class, 'OneToManyRelation', [_dec2], (0, _getOwnPropertyDescriptor2.default)(_class, 'OneToManyRelation'), _class), _applyDecoratedDescriptor(_class, 'getIdColumnArray', [_memoize2.default], (0, _getOwnPropertyDescriptor2.default)(_class, 'getIdColumnArray'), _class), _applyDecoratedDescriptor(_class, 'getFullIdColumn', [_memoize2.default], (0, _getOwnPropertyDescriptor2.default)(_class, 'getFullIdColumn'), _class), _applyDecoratedDescriptor(_class, 'getIdPropertyArray', [_memoize2.default], (0, _getOwnPropertyDescriptor2.default)(_class, 'getIdPropertyArray'), _class), _applyDecoratedDescriptor(_class, 'getIdProperty', [_memoize2.default], (0, _getOwnPropertyDescriptor2.default)(_class, 'getIdProperty'), _class), _applyDecoratedDescriptor(_class, 'relations', [_dec3], (0, _getOwnPropertyDescriptor2.default)(_class, 'relations'), _class), _applyDecoratedDescriptor(_class, 'relations', [_dec4], (0, _getOwnPropertyDescriptor2.default)(_class, 'relations'), _class)), _class));
exports.default = Model;

@@ -900,0 +905,0 @@

6

lib/queryBuilder/operations/FindOperation.js

@@ -58,7 +58,3 @@ 'use strict';

props = props || {};
var copy = new this.constructor(this.knex, this.name, props.opt || (0, _clone3.default)(this.opt));
copy.isWriteOperation = this.isWriteOperation;
return copy;
return new this.constructor(this.knex, this.name, props.opt || (0, _clone3.default)(this.opt));x;
};

@@ -65,0 +61,0 @@

@@ -75,2 +75,3 @@ 'use strict';

_this.allRelations = null;
_this.rootModelClass = null;
_this.pathInfo = (0, _create2.default)(null);

@@ -93,2 +94,3 @@ _this.encodings = (0, _create2.default)(null);

copy.allModelClasses = this.allModelClasses;
copy.rootModelClass = this.rootModelClass;
copy.pathInfo = this.pathInfo;

@@ -107,2 +109,3 @@ copy.encodings = this.encodings;

if (ret) {
this.rootModelClass = ModelClass;
this.allModelClasses = findAllModels(this.expression, ModelClass);

@@ -121,8 +124,7 @@ this.allRelations = findAllRelations(this.expression, ModelClass);

var builderClone = builder.clone();
var rootTable = builder.modelClass().tableName;
builder.table(rootTable + ' as ' + rootTable);
builder.table(this.rootModelClass.tableName + ' as ' + this.rootModelClass.tableName);
builder.findOptions({ callAfterGetDeeply: true });
this.buildForLevel({
this.build({
expr: this.expression,

@@ -133,3 +135,3 @@ builder: builder,

relation: null,
path: rootTable,
path: '',
selectFilter: function selectFilter(col) {

@@ -146,3 +148,3 @@ return builderClone.hasSelection(col);

var keyInfoByPath = this.createKeyInfo(builder.modelClass(), rows);
var keyInfoByPath = this.createKeyInfo(rows);
var pathInfo = _lodash2.default.values(this.pathInfo);

@@ -189,4 +191,3 @@

JoinEagerOperation.prototype.createKeyInfo = function createKeyInfo(modelClass, rows) {
var rootPath = modelClass.tableName;
JoinEagerOperation.prototype.createKeyInfo = function createKeyInfo(rows) {
var keys = (0, _keys2.default)(rows[0]);

@@ -200,3 +201,3 @@ var keyInfo = [];

if (sepIdx === -1) {
var pInfo = this.pathInfo[rootPath];
var pInfo = this.pathInfo[''];
var col = key;

@@ -257,3 +258,3 @@

JoinEagerOperation.prototype.buildForLevel = function buildForLevel(_ref) {
JoinEagerOperation.prototype.build = function build(_ref) {
var _this2 = this;

@@ -286,4 +287,4 @@

forEachExpr(expr, modelClass, function (childExpr, relation, relName) {
var nextPath = '' + path + _this2.sep + relName;
forEachExpr(expr, modelClass, function (childExpr, relation) {
var nextPath = _this2.joinPath(path, relation.name);
var encNextPath = _this2.encode(nextPath);

@@ -318,3 +319,3 @@ var encJoinTablePath = _this2.encode(joinTableForPath(nextPath));

_this2.buildForLevel({
_this2.build({
expr: childExpr,

@@ -374,2 +375,3 @@ builder: builder,

var idCols = modelClass.getIdColumnArray();
var rootTable = this.rootModelClass.tableName;

@@ -382,4 +384,4 @@ columnInfo[modelClass.tableName].columns.forEach(function (col) {

selects.push({
col: info.encPath + '.' + col,
alias: '' + info.encPath + _this3.sep + col
col: (info.encPath || rootTable) + '.' + col,
alias: _this3.joinPath(info.encPath, col)
});

@@ -401,3 +403,3 @@

col: joinTable + '.' + col,
alias: '' + info.encPath + _this3.sep + col
alias: _this3.joinPath(info.encPath, col)
});

@@ -434,3 +436,3 @@ }

// Don't encode the root.
if (parts.length === 1) {
if (!path) {
encPath = path;

@@ -453,3 +455,3 @@ } else {

// Don't encode the root.
if (path.indexOf(this.sep) === -1) {
if (!path) {
_encPath = path;

@@ -480,3 +482,3 @@ } else {

var idCols = modelClass.getIdColumnArray().map(function (col) {
return '' + path + _this5.sep + col;
return _this5.joinPath(path, col);
});

@@ -495,2 +497,10 @@

JoinEagerOperation.prototype.joinPath = function joinPath(path, nextPart) {
if (path) {
return '' + path + this.sep + nextPart;
} else {
return nextPart;
}
};
(0, _createClass3.default)(JoinEagerOperation, [{

@@ -497,0 +507,0 @@ key: 'sep',

@@ -265,3 +265,4 @@ 'use strict';

/**
* @param {function(QueryBuilder):EagerOperation} factory
* @param {function(QueryBuilder):EagerOperation} algorithm
* @param {object=} eagerOptions
* @returns {QueryBuilder}

@@ -271,4 +272,9 @@ */

QueryBuilder.prototype.eagerOperationFactory = function eagerOperationFactory(factory) {
this._eagerOperationFactory = factory;
QueryBuilder.prototype.eagerAlgorithm = function eagerAlgorithm(algorithm, eagerOptions) {
this.eagerOperationFactory(algorithm);
if (eagerOptions) {
this.eagerOptions(eagerOptions);
}
return this;

@@ -278,3 +284,3 @@ };

/**
* @param {function(QueryBuilder):EagerOperation} algorithm
* @param {function(QueryBuilder):EagerOperation} factory
* @returns {QueryBuilder}

@@ -284,4 +290,5 @@ */

QueryBuilder.prototype.eagerAlgorithm = function eagerAlgorithm(algorithm) {
return this.eagerOperationFactory(algorithm);
QueryBuilder.prototype.eagerOperationFactory = function eagerOperationFactory(factory) {
this._eagerOperationFactory = factory;
return this;
};

@@ -833,4 +840,5 @@

var operation = this._findOperationFactory(this);
operation.opt = (0, _assign2.default)(operation.opt, this._findOperationOptions);
operation.opt = _lodash2.default.merge(operation.opt, this._findOperationOptions);
this.callQueryBuilderOperation(operation, [], /* pushFront = */true);

@@ -848,4 +856,5 @@ }

var operation = this._eagerOperationFactory(this);
operation.opt = (0, _assign2.default)(operation.opt, this._eagerOperationOptions);
operation.opt = _lodash2.default.merge(operation.opt, this._modelClass.defaultEagerOptions, this._eagerOperationOptions);
this.callQueryBuilderOperation(operation, [this._eagerExpression, this._eagerFilterExpressions]);

@@ -852,0 +861,0 @@ }

{
"name": "objection",
"version": "0.6.0-rc.4",
"version": "0.6.0-rc.5",
"description": "An SQL-friendly ORM for Node.js",

@@ -10,3 +10,3 @@ "main": "lib/objection.js",

"test": "npm run build && istanbul --config=.istanbul.yml cover _mocha -- --slow 10 --timeout 15000 --reporter spec --recursive tests",
"perf": "mocha --slow 60000 --timeout 60000 --reporter spec --recursive perf",
"test-travis": "npm run build && istanbul --config=.istanbul.yml cover _mocha -- --slow 100 --timeout 60000 --reporter spec --recursive tests",
"test-bail": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests --bail",

@@ -16,2 +16,3 @@ "test-only": "mocha --slow 10 --timeout 15000 --reporter spec --recursive tests",

"coveralls": "cat ./testCoverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
"perf": "mocha --slow 60000 --timeout 60000 --reporter spec --recursive perf",
"prepublish": "npm run build"

@@ -18,0 +19,0 @@ },

@@ -113,2 +113,7 @@ import _ from 'lodash';

/**
* @type {object}
*/
static defaultEagerOptions = null;
/**
* @private

@@ -115,0 +120,0 @@ */

@@ -11,7 +11,3 @@ import clone from 'lodash/clone';

props = props || {};
const copy = new this.constructor(this.knex, this.name, props.opt || clone(this.opt));
copy.isWriteOperation = this.isWriteOperation;
return copy;
return new this.constructor(this.knex, this.name, props.opt || clone(this.opt));x
}

@@ -18,0 +14,0 @@

@@ -20,2 +20,3 @@ import _ from 'lodash';

this.allRelations = null;
this.rootModelClass = null;
this.pathInfo = Object.create(null);

@@ -37,2 +38,3 @@ this.encodings = Object.create(null);

copy.allModelClasses = this.allModelClasses;
copy.rootModelClass = this.rootModelClass;
copy.pathInfo = this.pathInfo;

@@ -51,2 +53,3 @@ copy.encodings = this.encodings;

if (ret) {
this.rootModelClass = ModelClass;
this.allModelClasses = findAllModels(this.expression, ModelClass);

@@ -65,8 +68,7 @@ this.allRelations = findAllRelations(this.expression, ModelClass);

const builderClone = builder.clone();
const rootTable = builder.modelClass().tableName;
builder.table(`${rootTable} as ${rootTable}`);
builder.table(`${this.rootModelClass.tableName} as ${this.rootModelClass.tableName}`);
builder.findOptions({callAfterGetDeeply: true});
this.buildForLevel({
this.build({
expr: this.expression,

@@ -77,3 +79,3 @@ builder: builder,

relation: null,
path: rootTable,
path: '',
selectFilter: (col) => {

@@ -90,3 +92,3 @@ return builderClone.hasSelection(col);

const keyInfoByPath = this.createKeyInfo(builder.modelClass(), rows);
const keyInfoByPath = this.createKeyInfo(rows);
const pathInfo = _.values(this.pathInfo);

@@ -133,4 +135,3 @@

createKeyInfo(modelClass, rows) {
const rootPath = modelClass.tableName;
createKeyInfo(rows) {
const keys = Object.keys(rows[0]);

@@ -144,3 +145,3 @@ const keyInfo = [];

if (sepIdx === -1) {
const pInfo = this.pathInfo[rootPath];
const pInfo = this.pathInfo[''];
const col = key;

@@ -199,3 +200,3 @@

buildForLevel({expr, builder, selectFilter, modelClass, relation, path, parentInfo}) {
build({expr, builder, selectFilter, modelClass, relation, path, parentInfo}) {
const info = this.createPathInfo({

@@ -218,4 +219,4 @@ modelClass,

forEachExpr(expr, modelClass, (childExpr, relation, relName) => {
const nextPath = `${path}${this.sep}${relName}`;
forEachExpr(expr, modelClass, (childExpr, relation) => {
const nextPath = this.joinPath(path, relation.name);
const encNextPath = this.encode(nextPath);

@@ -250,3 +251,3 @@ const encJoinTablePath = this.encode(joinTableForPath(nextPath));

this.buildForLevel({
this.build({
expr: childExpr,

@@ -293,2 +294,3 @@ builder: builder,

const idCols = modelClass.getIdColumnArray();
const rootTable = this.rootModelClass.tableName;

@@ -301,4 +303,4 @@ columnInfo[modelClass.tableName].columns.forEach(col => {

selects.push({
col: `${info.encPath}.${col}`,
alias: `${info.encPath}${this.sep}${col}`
col: `${info.encPath || rootTable}.${col}`,
alias: this.joinPath(info.encPath, col)
});

@@ -319,3 +321,3 @@

col: `${joinTable}.${col}`,
alias: `${info.encPath}${this.sep}${col}`
alias: this.joinPath(info.encPath, col)
});

@@ -346,3 +348,3 @@ }

// Don't encode the root.
if (parts.length === 1) {
if (!path) {
encPath = path;

@@ -363,3 +365,3 @@ } else {

// Don't encode the root.
if (path.indexOf(this.sep) === -1) {
if (!path) {
encPath = path;

@@ -387,3 +389,3 @@ } else {

createIdGetter(modelClass, path) {
const idCols = modelClass.getIdColumnArray().map(col => `${path}${this.sep}${col}`);
const idCols = modelClass.getIdColumnArray().map(col => this.joinPath(path, col));

@@ -404,2 +406,10 @@ if (idCols.length === 1) {

}
joinPath(path, nextPart) {
if (path) {
return `${path}${this.sep}${nextPart}`;
} else {
return nextPart;
}
}
}

@@ -406,0 +416,0 @@

@@ -121,7 +121,13 @@ import _ from 'lodash';

/**
* @param {function(QueryBuilder):EagerOperation} factory
* @param {function(QueryBuilder):EagerOperation} algorithm
* @param {object=} eagerOptions
* @returns {QueryBuilder}
*/
eagerOperationFactory(factory) {
this._eagerOperationFactory = factory;
eagerAlgorithm(algorithm, eagerOptions) {
this.eagerOperationFactory(algorithm);
if (eagerOptions) {
this.eagerOptions(eagerOptions);
}
return this;

@@ -131,7 +137,8 @@ }

/**
* @param {function(QueryBuilder):EagerOperation} algorithm
* @param {function(QueryBuilder):EagerOperation} factory
* @returns {QueryBuilder}
*/
eagerAlgorithm(algorithm) {
return this.eagerOperationFactory(algorithm);
eagerOperationFactory(factory) {
this._eagerOperationFactory = factory;
return this;
}

@@ -614,4 +621,7 @@

const operation = this._findOperationFactory(this);
operation.opt = Object.assign(operation.opt, this._findOperationOptions);
operation.opt = _.merge(operation.opt,
this._findOperationOptions
);
this.callQueryBuilderOperation(operation, [], /* pushFront = */ true);

@@ -627,4 +637,8 @@ }

const operation = this._eagerOperationFactory(this);
operation.opt = Object.assign(operation.opt, this._eagerOperationOptions);
operation.opt = _.merge(operation.opt,
this._modelClass.defaultEagerOptions,
this._eagerOperationOptions
);
this.callQueryBuilderOperation(operation, [

@@ -631,0 +645,0 @@ this._eagerExpression,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc