From ebe88a0d33a84018a453754fffe216ef295b7418 Mon Sep 17 00:00:00 2001 From: Tobias Gurtzick Date: Wed, 15 Apr 2020 18:27:06 +0200 Subject: [PATCH] fix(changeColumn): chain, not callbacks for passthrough Signed-off-by: Tobias Gurtzick --- index.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/index.js b/index.js index 81b37af..fc8e0c2 100644 --- a/index.js +++ b/index.js @@ -455,7 +455,7 @@ var PgDriver = Base.extend({ callback = null; } - return setNotNull.call(this); + return setNotNull.call(this).nodeify(callback); function setNotNull() { var setOrDrop = columnSpec.notNull === true ? 'SET' : 'DROP'; @@ -466,14 +466,10 @@ var PgDriver = Base.extend({ setOrDrop ); - return this.runSql(sql).nodeify(setUnique.bind(this)); + return this.runSql(sql).then(setUnique.bind(this)); } - function setUnique(err) { - if (err) { - return Promise.reject(err); - } - + function setUnique() { var sql; var constraintName = tableName + '_' + columnName + '_key'; @@ -484,24 +480,20 @@ var PgDriver = Base.extend({ constraintName, columnName ); - return this.runSql(sql).nodeify(setDefaultValue.bind(this)); + return this.runSql(sql).then(setDefaultValue.bind(this)); } else if (columnSpec.unique === false) { sql = util.format( 'ALTER TABLE "%s" DROP CONSTRAINT "%s"', tableName, constraintName ); - return this.runSql(sql).nodeify(setDefaultValue.bind(this)); + return this.runSql(sql).then(setDefaultValue.bind(this)); } else { return setDefaultValue.call(this); } } - function setDefaultValue(err) { - if (err) { - return Promise.reject(err).nodeify(callback); - } - + function setDefaultValue() { var sql; if (columnSpec.defaultValue !== undefined) { @@ -524,9 +516,7 @@ var PgDriver = Base.extend({ columnName ); } - return this.runSql(sql) - .then(setType.bind(this)) - .nodeify(callback); + return this.runSql(sql).then(setType.bind(this)); } function setType() {