Merge pull request #300 from strongloop/fix/allow-user-specific-pk-datatype
Honour user specific pk datatype
This commit is contained in:
commit
c227b22701
|
@ -582,8 +582,8 @@ function mixinMigration(MySQL, mysql) {
|
||||||
var idName = this.idName(model);
|
var idName = this.idName(model);
|
||||||
var idProp = this.getModelDefinition(model).properties[idName];
|
var idProp = this.getModelDefinition(model).properties[idName];
|
||||||
if (idProp.generated) {
|
if (idProp.generated) {
|
||||||
sql.push(self.columnEscaped(model, idName) +
|
sql.push(self.columnEscaped(model, idName) + ' ' +
|
||||||
' INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY');
|
self.buildColumnDefinition(model, idName) + ' AUTO_INCREMENT PRIMARY KEY');
|
||||||
} else {
|
} else {
|
||||||
idProp.nullable = false;
|
idProp.nullable = false;
|
||||||
sql.push(self.columnEscaped(model, idName) + ' ' +
|
sql.push(self.columnEscaped(model, idName) + ' ' +
|
||||||
|
|
|
@ -10,7 +10,7 @@ var platform = require('./helpers/platform');
|
||||||
var should = require('./init');
|
var should = require('./init');
|
||||||
var Schema = require('loopback-datasource-juggler').Schema;
|
var Schema = require('loopback-datasource-juggler').Schema;
|
||||||
|
|
||||||
var db, UserData, StringData, NumberData, DateData;
|
var db, UserData, StringData, NumberData, DateData, SimpleEmployee;
|
||||||
var mysqlVersion;
|
var mysqlVersion;
|
||||||
|
|
||||||
describe('migrations', function() {
|
describe('migrations', function() {
|
||||||
|
@ -22,6 +22,16 @@ describe('migrations', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('allow user specified datatype on PK', function(done) {
|
||||||
|
query('describe SimpleEmployee', function(err, result) {
|
||||||
|
should.not.exist(err);
|
||||||
|
should.exist(result);
|
||||||
|
result[0].Key.should.equal('PRI');
|
||||||
|
result[0].Type.should.equal('bigint(20)');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('UserData should have correct columns', function(done) {
|
it('UserData should have correct columns', function(done) {
|
||||||
getFields('UserData', function(err, fields) {
|
getFields('UserData', function(err, fields) {
|
||||||
if (!fields) return done();
|
if (!fields) return done();
|
||||||
|
@ -498,6 +508,11 @@ function setup(done) {
|
||||||
timestamp: {type: Date, dataType: 'timestamp'},
|
timestamp: {type: Date, dataType: 'timestamp'},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SimpleEmployee = db.define('SimpleEmployee', {
|
||||||
|
eId: {type: Number, generated: true, id: true, mysql: {dataType: 'bigint', dataLength: 20}},
|
||||||
|
name: {type: String},
|
||||||
|
});
|
||||||
|
|
||||||
query('SELECT VERSION()', function(err, res) {
|
query('SELECT VERSION()', function(err, res) {
|
||||||
mysqlVersion = res && res[0] && res[0]['VERSION()'];
|
mysqlVersion = res && res[0] && res[0]['VERSION()'];
|
||||||
blankDatabase(db, done);
|
blankDatabase(db, done);
|
||||||
|
|
Loading…
Reference in New Issue