Merge 26608c89e2
into 4c4ddb8ea5
This commit is contained in:
commit
cbd281159e
|
@ -301,6 +301,15 @@ function mixinDiscovery(MySQL, mysql) {
|
||||||
return sql;
|
return sql;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build query to determine is strict mode
|
||||||
|
*/
|
||||||
|
|
||||||
|
MySQL.prototype.buildQueryIsStrict = function() {
|
||||||
|
return 'SELECT @@GLOBAL.sql_mode LIKE \'%STRICT%\' AS globalStrictMode,' +
|
||||||
|
'@@SESSION.sql_mode LIKE \'%STRICT%\' AS sessionStrictMode;';
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discover foreign keys that reference to the primary key of this table
|
* Discover foreign keys that reference to the primary key of this table
|
||||||
* @param {String} table The table name
|
* @param {String} table The table name
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
process.env.NODE_ENV = 'test';
|
process.env.NODE_ENV = 'test';
|
||||||
const should = require('should');
|
const should = require('should');
|
||||||
|
const async = require('async');
|
||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const DataSource = require('loopback-datasource-juggler').DataSource;
|
const DataSource = require('loopback-datasource-juggler').DataSource;
|
||||||
|
@ -588,3 +589,25 @@ describe('Discover and build models', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Discover schema with strict mode on', function() {
|
||||||
|
let schema;
|
||||||
|
before(function(done) {
|
||||||
|
async.series([
|
||||||
|
db.execute('SET GLOBAL sql_mode = \'STRICT_ALL_TABLES\';'),
|
||||||
|
db.discoverSchema('INVENTORY', {owner: 'STRONGLOOP'}, function(err, schema_) {
|
||||||
|
schema = schema_;
|
||||||
|
done(err);
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
it('should return an LDL schema for INVENTORY with strict mode on', function() {
|
||||||
|
assert.strictEqual(schema.name, 'Inventory');
|
||||||
|
Object.keys(schema.properties).forEach(property => {
|
||||||
|
if (schema.properties.length) {
|
||||||
|
assert.strictEqual(property.jsonSchema.maxLength, property.length);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
async.series([db.execute('SET GLOBAL sql_mode = \'\';')]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue