fix: discover properties with json type
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
This commit is contained in:
parent
3ae4b5ecf0
commit
77b2c401f8
|
@ -382,6 +382,8 @@ function mixinDiscovery(MySQL, mysql) {
|
|||
case 'BOOL':
|
||||
case 'BOOLEAN':
|
||||
return 'Boolean';
|
||||
case 'JSON':
|
||||
return 'object';
|
||||
case 'ENUM':
|
||||
return columnType;
|
||||
default:
|
||||
|
|
|
@ -299,6 +299,22 @@ describe('Discover and handle enum', function() {
|
|||
});
|
||||
});
|
||||
|
||||
describe('Discover models with JSON type columns', function() {
|
||||
let schema;
|
||||
before(function(done) {
|
||||
db.discoverSchema('INVENTORY', {owner: 'STRONGLOOP'}, function(err, schema_) {
|
||||
schema = schema_;
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
it('should validate JSON as an object type for INVENTORY', function() {
|
||||
assert.ok(/STRONGLOOP/i.test(schema.options.mysql.schema));
|
||||
assert.strictEqual(schema.options.mysql.table, 'INVENTORY');
|
||||
assert.strictEqual(schema.name, 'Inventory');
|
||||
assert.strictEqual(schema.properties.details.type, 'object');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Discover and build models', function() {
|
||||
let models;
|
||||
before(function(done) {
|
||||
|
|
|
@ -78,6 +78,7 @@ CREATE TABLE `INVENTORY` (
|
|||
`LOCATION_ID` varchar(20) NOT NULL,
|
||||
`AVAILABLE` int(11) DEFAULT NULL,
|
||||
`TOTAL` int(11) DEFAULT NULL,
|
||||
`DETAILS` json DEFAULT NULL,
|
||||
`ACTIVE` BOOLEAN DEFAULT TRUE,
|
||||
`DISABLED` BIT(1) DEFAULT 0,
|
||||
`ENABLED` CHAR(1) DEFAULT 'Y',
|
||||
|
|
Loading…
Reference in New Issue