Tests for autoupdate mysql.columnName bug fix
This commit is contained in:
parent
89766587b3
commit
0de8dc7c97
|
@ -13,6 +13,10 @@ before(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('MySQL connector', function() {
|
describe('MySQL connector', function() {
|
||||||
|
before(function () {
|
||||||
|
setupAltColNameData();
|
||||||
|
});
|
||||||
|
|
||||||
it('should auto migrate/update tables', function(done) {
|
it('should auto migrate/update tables', function(done) {
|
||||||
var schema_v1 =
|
var schema_v1 =
|
||||||
{
|
{
|
||||||
|
@ -163,6 +167,37 @@ describe('MySQL connector', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function setupAltColNameData() {
|
||||||
|
var schema = {
|
||||||
|
"name": "ColRenameTest",
|
||||||
|
"options": {
|
||||||
|
"idInjection": false,
|
||||||
|
"mysql": {
|
||||||
|
"schema": "myapp_test",
|
||||||
|
"table": "col_rename_test"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"firstName": {
|
||||||
|
"type": "String",
|
||||||
|
"required": false,
|
||||||
|
"length": 40,
|
||||||
|
"mysql": {
|
||||||
|
"columnName": "first_name",
|
||||||
|
"dataType": "varchar",
|
||||||
|
"dataLength": 40
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"lastName": {
|
||||||
|
"type": "String",
|
||||||
|
"required": false,
|
||||||
|
"length": 40
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ds.createModel(schema.name, schema.properties, schema.options);
|
||||||
|
}
|
||||||
|
|
||||||
it('should report errors for automigrate', function(done) {
|
it('should report errors for automigrate', function(done) {
|
||||||
ds.automigrate('XYZ', function(err) {
|
ds.automigrate('XYZ', function(err) {
|
||||||
assert(err);
|
assert(err);
|
||||||
|
@ -176,4 +211,25 @@ describe('MySQL connector', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('"mysql.columnName" is updated with correct name on create table', function (done) {
|
||||||
|
// first autoupdate call uses create table
|
||||||
|
verifyMysqlColumnNameAutoupdate(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('"mysql.columnName" is updated without changing column name on alter table', function (done) {
|
||||||
|
// second autoupdate call uses alter table
|
||||||
|
verifyMysqlColumnNameAutoupdate(done);
|
||||||
|
});
|
||||||
|
|
||||||
|
function verifyMysqlColumnNameAutoupdate(done) {
|
||||||
|
ds.autoupdate('ColRenameTest', function (err) {
|
||||||
|
ds.discoverModelProperties('col_rename_test', function (err, props) {
|
||||||
|
assert.equal(props[0].columnName, 'first_name');
|
||||||
|
assert.equal(props[1].columnName, 'lastName');
|
||||||
|
assert.equal(props.length, 2);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue