commit
0fcaa35f52
|
@ -4,3 +4,5 @@ coverage
|
|||
*.xml
|
||||
.loopbackrc
|
||||
.idea
|
||||
intl/*
|
||||
!intl/en/
|
3
index.js
3
index.js
|
@ -3,4 +3,7 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
var SG = require('strong-globalize');
|
||||
SG.SetRootDir(__dirname);
|
||||
|
||||
module.exports = require('./lib/mysql.js');
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"6ce5c3a3d305e965ff06e2b3e16e1252": "{{options}} must be an {{object}}: {0}",
|
||||
"a0078d732b2dbabf98ed2efcdb55b402": "{{table}} is a required string argument: {0}",
|
||||
"b7c60421de706ca1e050f2a86953745e": "No arguments - could not create {{Enum}}.",
|
||||
"80a32e80cbed65eba2103201a7c94710": "Model not found: {0}",
|
||||
"026ed55518f3812a9ef4b86e8a195e76": "{{MySQL}} {{regex}} syntax does not respect the {{`g`}} flag",
|
||||
"0ac9f848b934332210bb27747d12a033": "{{MySQL}} {{regex}} syntax does not respect the {{`i`}} flag",
|
||||
"4e9e35876bfb1511205456b52c6659d0": "{{MySQL}} {{regex}} syntax does not respect the {{`m`}} flag",
|
||||
"57512a471969647e8eaa2509cc292018": "{{callback}} should be a function"
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
var g = require('strong-globalize')();
|
||||
|
||||
module.exports = mixinDiscovery;
|
||||
|
||||
/*!
|
||||
|
@ -167,7 +169,7 @@ function mixinDiscovery(MySQL, mysql) {
|
|||
*/
|
||||
function getArgs(table, options, cb) {
|
||||
if ('string' !== typeof table || !table) {
|
||||
throw new Error('table is a required string argument: ' + table);
|
||||
throw new Error(g.f('{{table}} is a required string argument: %s', table));
|
||||
}
|
||||
options = options || {};
|
||||
if (!cb && 'function' === typeof options) {
|
||||
|
@ -175,7 +177,7 @@ function mixinDiscovery(MySQL, mysql) {
|
|||
options = {};
|
||||
}
|
||||
if (typeof options !== 'object') {
|
||||
throw new Error('options must be an object: ' + options);
|
||||
throw new Error(g.f('{{options}} must be an {{object}}: %s', options));
|
||||
}
|
||||
return {
|
||||
schema: options.owner || options.schema,
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
var g = require('strong-globalize')();
|
||||
|
||||
var EnumFactory = function() {
|
||||
if (arguments.length > 0) {
|
||||
var Enum = function Enum(arg) {
|
||||
|
@ -47,7 +49,7 @@ var EnumFactory = function() {
|
|||
Object.freeze(Enum);
|
||||
return Enum;
|
||||
} else {
|
||||
throw "No arguments - could not create Enum.";
|
||||
throw g.f("No arguments - could not create {{Enum}}.");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
var g = require('strong-globalize')();
|
||||
var async = require('async');
|
||||
module.exports = mixinMigration;
|
||||
|
||||
|
@ -34,7 +35,7 @@ function mixinMigration(MySQL, mysql) {
|
|||
async.each(models, function(model, done) {
|
||||
if (!(model in self._models)) {
|
||||
return process.nextTick(function() {
|
||||
done(new Error('Model not found: ' + model));
|
||||
done(new Error(g.f('Model not found: %s', model)));
|
||||
});
|
||||
}
|
||||
var table = self.tableEscaped(model);
|
||||
|
|
10
lib/mysql.js
10
lib/mysql.js
|
@ -3,6 +3,8 @@
|
|||
// This file is licensed under the MIT License.
|
||||
// License text available at https://opensource.org/licenses/MIT
|
||||
|
||||
var g = require('strong-globalize')();
|
||||
|
||||
/*!
|
||||
* Module dependencies
|
||||
*/
|
||||
|
@ -164,7 +166,7 @@ MySQL.prototype.executeSQL = function(sql, params, options, callback) {
|
|||
var debugEnabled = debug.enabled;
|
||||
var db = this.settings.database;
|
||||
if (typeof callback !== 'function') {
|
||||
throw new Error('callback should be a function');
|
||||
throw new Error(g.f('{{callback}} should be a function'));
|
||||
}
|
||||
if (debugEnabled) {
|
||||
debug('SQL: %s, params: %j', sql, params);
|
||||
|
@ -517,13 +519,13 @@ MySQL.prototype.buildExpression = function(columnName, operator, operatorValue,
|
|||
propertyDefinition) {
|
||||
if (operator === 'regexp') {
|
||||
if (operatorValue.ignoreCase)
|
||||
console.warn('MySQL regex syntax does not respect the `i` flag');
|
||||
g.warn('{{MySQL}} {{regex}} syntax does not respect the {{`i`}} flag');
|
||||
|
||||
if (operatorValue.global)
|
||||
console.warn('MySQL regex syntax does not respect the `g` flag');
|
||||
g.warn('{{MySQL}} {{regex}} syntax does not respect the {{`g`}} flag');
|
||||
|
||||
if (operatorValue.multiline)
|
||||
console.warn('MySQL regex syntax does not respect the `m` flag');
|
||||
g.warn('{{MySQL}} {{regex}} syntax does not respect the {{`m`}} flag');
|
||||
|
||||
return new ParameterizedSQL(columnName + ' REGEXP ?',
|
||||
[operatorValue.source]);
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
"async": "^0.9.0",
|
||||
"debug": "^2.1.1",
|
||||
"loopback-connector": "^2.1.0",
|
||||
"mysql": "^2.5.4"
|
||||
"mysql": "^2.5.4",
|
||||
"strong-globalize": "^2.5.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bluebird": "~2.9.10",
|
||||
|
|
Loading…
Reference in New Issue