Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@knorm/knorm

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@knorm/knorm - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="1.0.1"></a>
## [1.0.1](https://github.com/knorm/knorm/compare/v1.0.0...v1.0.1) (2018-07-05)
### Bug Fixes
* **Query:** add validation for undefined `where` values ([de888d8](https://github.com/knorm/knorm/commit/de888d8))
<a name="1.0.0"></a>

@@ -2,0 +12,0 @@ # [1.0.0](https://github.com/knorm/knorm/compare/v1.0.0-next...v1.0.0) (2018-06-27)

35

lib/Query.js

@@ -254,6 +254,16 @@ const { difference } = require('lodash');

getWhere(where, { type } = {}) {
getWhere(where, options = {}) {
const [field, value, ...rest] = where;
if (isString(field)) {
const { type, forHaving } = options;
if (value === undefined) {
throw new this.constructor.QueryError(
`${this.model.name}: undefined "${
forHaving ? 'having' : 'where'
}" value passed for field \`${field}\``
);
}
// TODO: upstream `in` with an empty array to sql-bricks

@@ -268,2 +278,9 @@ if (type === 'in' && !value.length) {

if (type === 'between' && isArray(value)) {
if (!value.length) {
throw new this.constructor.QueryError(
`${
this.model.name
}: empty array passed for "between" for field \`${field}\``
);
}
return [column, ...value, ...rest];

@@ -284,3 +301,6 @@ }

const type = field.slice(3);
const where = this.getWhere(value, { type });
const where = this.getWhere(
value,
Object.assign(options, { type })
);
if (where instanceof this.sql) {

@@ -292,3 +312,4 @@ expressions.push(where);

} else {
expressions.push({ [this.getColumn(field)]: value });
const [column] = this.getWhere([field, value], options);
expressions.push({ [column]: value });
}

@@ -305,7 +326,7 @@ });

prepareWhere(sql, fields) {
return sql.where.apply(sql, this.getWhere(fields));
return sql.where.apply(sql, this.getWhere(fields, { forWhere: true }));
}
prepareHaving(sql, fields) {
return sql.having.apply(sql, this.getWhere(fields));
return sql.having.apply(sql, this.getWhere(fields, { forHaving: true }));
}

@@ -423,3 +444,5 @@

throw new this.constructor.QueryError(
'all objects should have the same field count'
`${this.model.name}: all objects for ${
options.forUpdate ? 'update' : 'insert'
} should have the same number of fields`
);

@@ -426,0 +449,0 @@ }

2

package.json
{
"name": "@knorm/knorm",
"version": "1.0.0",
"version": "1.0.1",
"description": "A purely ES6 class-based ORM for Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc