New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

loopback-connector-mysql

Package Overview
Dependencies
Maintainers
4
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loopback-connector-mysql - npm Package Compare versions

Comparing version 1.6.0 to 1.7.0

24

CHANGES.md

@@ -1,4 +0,26 @@

2015-02-21, Version 1.6.0
2015-04-02, Version 1.7.0
=========================
* Return isNewInstance from upsert (Raymond Feng)
* Update rc dep (Raymond Feng)
* Return count when updating or deleting models (Simon Ho)
* Update README.md (Simon Ho)
* Add test running instructions to readme (Simon Ho)
* Fix mysql neq for NULL value. (ulion)
* replace dataLength instead of adding length property (Partap Davis)
* Allow models backed by MySQL to reference mongodb ObjectID (Raymond Feng)
* Query string length for schema in characters in addition to bytes (Partap Davis)
2015-02-20, Version 1.6.0
=========================
* Update deps (Raymond Feng)

@@ -5,0 +27,0 @@

4

lib/discovery.js

@@ -147,3 +147,3 @@ module.exports = mixinDiscovery;

' data_type AS "dataType",' +
' character_octet_length AS "dataLength",' +
' character_maximum_length AS "dataLength",' +
' numeric_precision AS "dataPrecision",' +

@@ -160,3 +160,3 @@ ' numeric_scale AS "dataScale",' +

' data_type AS "dataType",' +
' character_octet_length AS "dataLength",' +
' character_maximum_length AS "dataLength",' +
' numeric_precision AS "dataPrecision",' +

@@ -163,0 +163,0 @@ ' numeric_scale AS "dataScale",' +

@@ -257,7 +257,15 @@ /*!

this.query(sql, function (err, info) {
this.query(sql, function(err, info) {
if (!err && info && info.insertId) {
data.id = info.insertId;
}
callback(err, data);
var meta = {};
if (info) {
// When using the INSERT ... ON DUPLICATE KEY UPDATE statement,
// the returned value is as follows:
// 1 for each successful INSERT.
// 2 for each successful UPDATE.
meta.isNewInstance = (info.affectedRows === 1);
}
callback(err, data, meta);
});

@@ -327,2 +335,5 @@ };

}
if (prop.type === String) {
return this.client.escape(String(val));
}
if (prop.type === Number) {

@@ -350,14 +361,23 @@ if (isNaN(val)) {

if (prop.type === Object) {
return this.client.escape(val);
return this._serializeObject(val);
}
if (typeof prop.type === 'function') {
if (prop.type.modelName) {
// For embedded models
return this.client.escape(JSON.stringify(val));
}
return this.client.escape(prop.type(val));
return this._serializeObject(val);
}
return this.client.escape(val.toString());
return this._serializeObject(val);
};
MySQL.prototype._serializeObject = function(obj) {
var val;
if (obj && typeof obj.toJSON === 'function') {
obj = obj.toJSON();
}
if (typeof obj !== 'string') {
val = JSON.stringify(obj);
} else {
val = obj;
}
return this.client.escape(val);
};
/*!

@@ -387,2 +407,8 @@ * Convert the data from database

switch (props[p].type.name) {
case 'Number':
val = Number(val);
break;
case 'String':
val = String(val);
break;
case 'Date':

@@ -401,2 +427,13 @@ val = new Date(val.toString().replace(/GMT.*$/, 'GMT'));

break;
case 'List':
case 'Array':
case 'Object':
case 'JSON':
break;
default:
if (!Array.isArray(props[p].type) && !props[p].type.modelName) {
// Do not convert array and model types
val = props[p].type(val);
}
break;
}

@@ -507,3 +544,3 @@ }

case 'neq':
sqlCond += ' != ';
sqlCond += val === 'NULL' ? ' IS NOT ' : ' != ';
break;

@@ -621,3 +658,14 @@ case 'like':

MySQL.prototype.update =
MySQL.prototype.updateAll = function(model, where, data, cb) {
var query = 'UPDATE ' + this.tableEscaped(model) + ' SET ' +
this.toFields(model, data) + ' ' + this.buildWhere(model, where);
this.query(query, function(err, info) {
var affectedRows = info && typeof info.affectedRows === 'number' ?
info.affectedRows : undefined;
cb && cb(err, {count: affectedRows});
});
};
/**

@@ -638,4 +686,6 @@ * Delete instances for the given model

+ this.tableEscaped(model) + ' ' + this.buildWhere(model, where || {}),
function (err, data) {
callback && callback(err, data);
function(err, info) {
var affectedRows = info && typeof info.affectedRows === 'number' ?
info.affectedRows : undefined;
callback && callback(err, {count: affectedRows});
}.bind(this));

@@ -642,0 +692,0 @@ };

{
"name": "loopback-connector-mysql",
"version": "1.6.0",
"version": "1.7.0",
"description": "MySQL connector for loopback-datasource-juggler",

@@ -19,3 +19,3 @@ "main": "index.js",

"mocha": "^2.1.0",
"rc": "^0.6.0",
"rc": "^1.0.0",
"should": "^5.0.0"

@@ -32,4 +32,4 @@ },

"optionalDependencies": {
"sl-blip": "http://blip.strongloop.com/loopback-connector-mysql@1.6.0"
"sl-blip": "http://blip.strongloop.com/loopback-connector-mysql@1.7.0"
}
}

@@ -47,1 +47,7 @@ ## loopback-connector-mysql

## Running Tests
The tests in this repository are mainly integration tests, meaning you will need to run them using our preconfigured test server.
1. Ask a core developer for instructions on how to set up test server credentials on your machine
2. `npm test`

@@ -5,2 +5,15 @@ var should = require('./init.js');

// Mock up mongodb ObjectID
function ObjectID(id) {
if (!(this instanceof ObjectID)) {
return new ObjectID(id);
}
this.id1 = id.substring(0, 2);
this.id2 = id.substring(2);
}
ObjectID.prototype.toJSON = function() {
return this.id1 + this.id2;
};
describe('mysql', function () {

@@ -16,3 +29,4 @@

history: Object,
stars: Number
stars: Number,
userId: ObjectID
});

@@ -49,7 +63,7 @@

Post.create({title: 'a', content: 'AAA', comments: ['1', '2'],
history: {a: 1, b: 'b'}}, function (err, post) {
history: {a: 1, b: 'b'}}, function(err, post) {
should.not.exist(err);
Post.findById(post.id, function (err, p) {
Post.findById(post.id, function(err, p) {
p.id.should.be.equal(post.id);

@@ -65,3 +79,20 @@

});
});
it('should allow ObjectID', function(done) {
var uid = new ObjectID('123');
Post.create({title: 'a', content: 'AAA', userId: uid},
function(err, post) {
should.not.exist(err);
Post.findById(post.id, function(err, p) {
p.id.should.be.equal(post.id);
p.content.should.be.equal(post.content);
p.title.should.be.equal('a');
p.userId.should.eql(uid);
done();
});
});
});

@@ -68,0 +99,0 @@

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