Skip to content

Commit

Permalink
refactor: remove dependency on Bluebird.prototype.map in repository f…
Browse files Browse the repository at this point in the history
…or querying responses
  • Loading branch information
maxeljkin committed Oct 10, 2019
1 parent 6de2633 commit bc6e265
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
4 changes: 1 addition & 3 deletions lib/dialects/sqlite3/index.js
Expand Up @@ -122,9 +122,7 @@ Object.assign(Client_SQLite3.prototype, {
return client
._query(connection, sql)
.then((obj) => obj.response)
.map(function(row) {
stream.write(row);
})
.then((rows) => rows.forEach((row) => stream.write(row)))
.catch(function(err) {
stream.emit('error', err);
})
Expand Down
20 changes: 12 additions & 8 deletions lib/migrate/Migrator.js
Expand Up @@ -436,14 +436,18 @@ class Migrator {
qb.max('batch').from(getTableName(tableName, schemaName));
})
.orderBy('id', 'desc')
.map((migration) => {
return allMigrations.find((entry) => {
return (
this.config.migrationSource.getMigrationName(entry) ===
migration.name
);
});
});
.then((migrations) =>
Promise.all(
migrations.map((migration) => {
return allMigrations.find((entry) => {
return (
this.config.migrationSource.getMigrationName(entry) ===
migration.name
);
});
})
)
);
}

// Returns the latest batch number.
Expand Down
12 changes: 6 additions & 6 deletions test/integration/datatype/bigint.js
Expand Up @@ -28,15 +28,15 @@ module.exports = function(knex) {
.where('expiry', unsafeBigint)
.select('*');
})
.map(function(row) {
.then(function(row) {
// triggers request execution
})
.then(function() {
return knex(tableName)
.where('expiry', negativeUnsafeBigint)
.select('*');
})
.map(function(row) {
.then(function(row) {
// triggers request execution
})
.catch(function(err) {
Expand Down Expand Up @@ -79,16 +79,16 @@ module.exports = function(knex) {
.where('expiry', bigintTimestamp)
.select('*');
})
.map(function(row) {
expect(row.id).to.equal('positive');
.then(function(rows) {
rows.forEach((row) => expect(row.id).to.equal('positive'));
})
.then(function() {
return knex(tableName)
.where('expiry', negativeBigintTimestamp)
.select('*');
})
.map(function(row) {
expect(row.id).to.equal('negative');
.then(function(rows) {
rows.forEach((row) => expect(row.id).to.equal('negative'));
})
.catch(function(err) {
expect(err).to.be.undefined;
Expand Down

0 comments on commit bc6e265

Please sign in to comment.