Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behaviour of insert method when no callback is passed #10

Open
nikarh opened this issue Aug 30, 2017 · 1 comment
Open

Unexpected behaviour of insert method when no callback is passed #10

nikarh opened this issue Aug 30, 2017 · 1 comment

Comments

@nikarh
Copy link

nikarh commented Aug 30, 2017

The following code

exports.up = async function up(db) {
  await db.insert('test_table', ['data'], ['test']);
}

will fail with an error

/home/nikarh/workspace/agilestacks/automation-hub/api/node_modules/bluebird/js/release/async.js:61
        fn = function () { throw arg; };
                           ^

TypeError: callback is not a function
at Object.insert [as _super] (/home/nikarh/db-migrate-test/node_modules/db-migrate-base/index.js:366:14)
at Object.insert (/home/nikarh/db-migrate-test/node_modules/db-migrate-pg/index.js:440:26)
at Object.prototype.(anonymous function) (/home/nikarh/db-migrate-test/node_modules/db-migrate-base/class.js:36:24)
at Object.Interface.(anonymous function) [as insert] (/home/nikarh/db-migrate-test/node_modules/db-migrate-shared/util.js:135:41)
at Class.up (/home/nikarh/db-migrate-test/migrations/20170830131445-stack-table-data.js:4:14)
at Class.<anonymous> (/home/nikarh/db-migrate-test/node_modules/db-migrate/lib/skeleton.js:81:41)
at Promise._execute (/home/nikarh/db-migrate-test/node_modules/bluebird/js/release/debuggability.js:300:9)
at Promise._resolveFromExecutor (/home/nikarh/db-migrate-test/node_modules/bluebird/js/release/promise.js:483:18)
at new Promise (/home/nikarh/db-migrate-test/node_modules/bluebird/js/release/promise.js:79:10)
at Class._up (/home/nikarh/db-migrate-test/node_modules/db-migrate/lib/skeleton.js:65:12)
at Class.up (/home/nikarh/db-migrate-test/node_modules/db-migrate/lib/skeleton.js:149:17)
at Migrator.up (/home/nikarh/db-migrate-test/node_modules/db-migrate/lib/migrator.js:112:14)
at /home/nikarh/db-migrate-test/node_modules/db-migrate/lib/migrator.js:178:25
at tryCatcher (/home/nikarh/db-migrate-test/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/nikarh/db-migrate-test/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/home/nikarh/db-migrate-test/node_modules/bluebird/js/release/promise.js:569:18)

I can do a PR, I suggest checking the type of a last argument to differentiate between promise-based and callback based API.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@Jesavino
Copy link

I'm seeing this issue still. Would be great if it could be resolved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants