Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/discovery.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ function mixinDiscovery(MySQL, mysql) {
case 'MEDIUMTEXT':
case 'LONGTEXT':
case 'TEXT':
case 'ENUM':
case 'SET':
return 'String';
case 'TINYBLOB':
Expand Down Expand Up @@ -380,6 +379,8 @@ function mixinDiscovery(MySQL, mysql) {
case 'BOOL':
case 'BOOLEAN':
return 'Boolean';
case 'ENUM':
return columnType;
default:
return 'String';
}
Expand Down
16 changes: 16 additions & 0 deletions test/mysql.discover.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ describe('Discover LDL schema from a table', function() {
});
});

describe('Discover and handle enum', function() {
let schema;
before(function(done) {
db.discoverSchema('PATIENT', {owner: 'STRONGLOOP'}, function(err, schema_) {
schema = schema_;
done(err);
});
});
it('should validate enum type for PATIENT', function() {
assert.ok(/STRONGLOOP/i.test(schema.options.mysql.schema));
assert.strictEqual(schema.options.mysql.table, 'PATIENT');
assert.strictEqual(schema.name, 'Patient');
assert.strictEqual(schema.properties.type.type, "enum('INPATIENT','OUTPATIENT')");
});
});

describe('Discover and build models', function() {
let models;
before(function(done) {
Expand Down
10 changes: 10 additions & 0 deletions test/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ LOCK TABLES `CUSTOMER` WRITE;
/*!40000 ALTER TABLE `CUSTOMER` ENABLE KEYS */;
UNLOCK TABLES;

DROP TABLE IF EXISTS `PATIENT`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `PATIENT` (
`ID` varchar(20) NOT NULL,
`NAME` varchar(20) NOT NULL,
`TYPE` ENUM('INPATIENT', 'OUTPATIENT') DEFAULT NULL,
PRIMARY KEY (`ID`),
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

--
-- Table structure for table `INVENTORY`
--
Expand Down