Skip to content

Commit 584b129

Browse files
author
Raymond Feng
committed
Fix the error handling for createTable
1 parent eddc5a2 commit 584b129

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

lib/migration.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ function mixinMigration(PostgreSQL) {
415415
self.propertiesSQL(model) + '\n)',
416416
function(err, info) {
417417
if (err) {
418-
cb(err, info);
418+
return cb(err, info);
419419
}
420420
self.addIndexes(model, undefined, cb);
421421
}

test/postgresql.dbdefaults.test.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,18 @@ describe('database default field values', function() {
5555
" where table_name = 'postwithdbdefaultvalue'" +
5656
" and column_name='created'";
5757

58-
db.connector.execute(query, function(err, results) {
59-
assert.equal(results[0].column_default, "now()");
60-
done(err);
61-
});
58+
function verifyColumnDefault() {
59+
db.connector.execute(query, [], function(err, results) {
60+
assert.equal(results[0].column_default, "now()");
61+
done(err);
62+
});
63+
}
64+
65+
if (db.connected) {
66+
verifyColumnDefault();
67+
} else {
68+
db.once('connected', verifyColumnDefault);
69+
}
6270
});
6371

6472
it('should create a record with default value', function(done) {

0 commit comments

Comments
 (0)