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

sails-disk

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sails-disk - npm Package Compare versions

Comparing version 0.10.5 to 0.10.6

37

lib/database.js

@@ -444,3 +444,12 @@ /**

// If uniqueness constraints were violated, send back a validation error.
var violations = self.enforceUniqueness(collectionName, values);
var pkAttrName = getPrimaryKey(this.schema[collectionName]);
// console.log('pkAttrName',pkAttrName);
var pkValueOfFirstRecordInResultSet = (function (){
// console.log('resultSet',resultSet.results);
if (resultSet.results && resultSet.results[0] && resultSet.results[0][pkAttrName]) {
return resultSet.results[0][pkAttrName];
}
return undefined;
})();
var violations = self.enforceUniqueness(collectionName, values, pkValueOfFirstRecordInResultSet);
if (violations.length) {

@@ -591,2 +600,3 @@ return cb(new UniquenessError(violations));

* @param {Object} values - attribute values for a single record
* @param {*} pkValueOfFirstRecordInResultSet - (optional) the primary key value of the record we're updating
* @return {Object}

@@ -596,3 +606,3 @@ * @api private

Database.prototype.enforceUniqueness = function(collectionName, values) {
Database.prototype.enforceUniqueness = function(collectionName, values, pkValueOfFirstRecordInResultSet) {

@@ -610,2 +620,3 @@ var errors = [];

// Loop through each record in our database
for (var index in this.data[collectionName]) {

@@ -617,2 +628,24 @@

// If `pkValueOfFirstRecordInResultSet` was provided, this must be an update,
// and we're updating the record with this pk value.
// e.g. if I'm updating record w/ id=3 to have email='foo@foo.com',
// but it already has an email='foo@foo.com', then this is not a
// uniqueness violation.
//
// (note that if I'm updating multiple records but providing only one value for
// a unique attribute, this will inevitably fail anyways-- this is why we only care
// about the first record in the result set)
if (pkValueOfFirstRecordInResultSet) {
var existingRecord = _.find(this.data[collectionName], function (record){
return record[pkAttrName] === pkValueOfFirstRecordInResultSet;
});
if (existingRecord) {
// It isn't actually a uniquness violation if the record
// we're checking is the same as the record we're updating/creating
if (values[attrName] === existingRecord[attrName]){
continue;
}
}
}
// Does it look like a "uniqueness violation"?

@@ -619,0 +652,0 @@ if (values[attrName] === this.data[collectionName][index][attrName]) {

2

package.json
{
"name": "sails-disk",
"version": "0.10.5",
"version": "0.10.6",
"description": "Persistent local-disk adapter for Sails.js / Waterline",

@@ -5,0 +5,0 @@ "main": "lib/adapter.js",

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