fix: change condition to treat tinyint as boolean
Signed-off-by: Muhammad Aaqil <aaqilcs102@gmail.com>
This commit is contained in:
parent
b057c20fe2
commit
8812d51862
|
@ -358,8 +358,8 @@ function mixinDiscovery(MySQL, mysql) {
|
||||||
}
|
}
|
||||||
return 'Binary';
|
return 'Binary';
|
||||||
case 'TINYINT':
|
case 'TINYINT':
|
||||||
// treat TINYINT(1) as boolean as it is aliased as BOOL and BOOLEAN in mysql
|
// treat TINYINT as boolean as it is aliased as BOOL and BOOLEAN in mysql
|
||||||
if (!options.treatTINYINT1AsTinyInt && columnType === 'tinyint(1)') {
|
if (!options.treatTINYINT1AsTinyInt && columnType.includes('tinyint')) {
|
||||||
return 'Boolean';
|
return 'Boolean';
|
||||||
}
|
}
|
||||||
case 'SMALLINT':
|
case 'SMALLINT':
|
||||||
|
|
|
@ -518,7 +518,6 @@ describe('Discover and build models', function() {
|
||||||
context('with flag treatTINYINT1AsTinyInt = false', function() {
|
context('with flag treatTINYINT1AsTinyInt = false', function() {
|
||||||
let models, schema;
|
let models, schema;
|
||||||
before(discoverAndBuildModels);
|
before(discoverAndBuildModels);
|
||||||
|
|
||||||
it('handles CHAR(1) as Boolean', function() {
|
it('handles CHAR(1) as Boolean', function() {
|
||||||
assert(schema.properties.enabled);
|
assert(schema.properties.enabled);
|
||||||
assert.strictEqual(schema.properties.enabled.type, Boolean);
|
assert.strictEqual(schema.properties.enabled.type, Boolean);
|
||||||
|
@ -568,6 +567,11 @@ describe('Discover and build models', function() {
|
||||||
assert.strictEqual(schema.properties.active.type, Boolean);
|
assert.strictEqual(schema.properties.active.type, Boolean);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('handles TINYINT as Boolean', function() {
|
||||||
|
assert(schema.properties.archived);
|
||||||
|
assert.strictEqual(schema.properties.archived.type, Boolean);
|
||||||
|
});
|
||||||
|
|
||||||
function discoverAndBuildModels(done) {
|
function discoverAndBuildModels(done) {
|
||||||
db.discoverAndBuildModels('INVENTORY', {
|
db.discoverAndBuildModels('INVENTORY', {
|
||||||
owner: 'STRONGLOOP',
|
owner: 'STRONGLOOP',
|
||||||
|
|
|
@ -80,6 +80,7 @@ CREATE TABLE `INVENTORY` (
|
||||||
`TOTAL` int(11) DEFAULT NULL,
|
`TOTAL` int(11) DEFAULT NULL,
|
||||||
`DETAILS` json DEFAULT NULL,
|
`DETAILS` json DEFAULT NULL,
|
||||||
`ACTIVE` BOOLEAN DEFAULT TRUE,
|
`ACTIVE` BOOLEAN DEFAULT TRUE,
|
||||||
|
`ARCHIVED` TINYINT DEFAULT 1,
|
||||||
`DISABLED` BIT(1) DEFAULT 0,
|
`DISABLED` BIT(1) DEFAULT 0,
|
||||||
`ENABLED` CHAR(1) DEFAULT 'Y',
|
`ENABLED` CHAR(1) DEFAULT 'Y',
|
||||||
PRIMARY KEY (`PRODUCT_ID`,`LOCATION_ID`),
|
PRIMARY KEY (`PRODUCT_ID`,`LOCATION_ID`),
|
||||||
|
|
Loading…
Reference in New Issue