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

feat(constructor): detect knex on construction #1756



Copy link

@cdaringe cdaringe commented Feb 6, 2018


a bad knex arg is allowed on construction


fail fast

Proposed solution

disallow a bad knex arg on construction

@@ -24,6 +24,9 @@ import Errors from './errors';
* @param {Knex} knex Knex instance.
function Bookshelf(knex) {
if (!knex || !knex.__knex__) {

This comment has been minimized.


ricardograca Feb 7, 2018

This started throwing a warning when running tests:

Knex:warning - knex.__knex__ is deprecated, you can get the module versionby running require('knex/package').version

Can you look into it?

This comment has been minimized.


cdaringe Feb 7, 2018
Author Contributor

yep. sorry i missed that.

@ricardograca ricardograca added the feature label Feb 7, 2018
@ricardograca ricardograca added this to To Do in Version 0.13.0 via automation Feb 7, 2018
@ricardograca ricardograca moved this from To Do to In Progress in Version 0.13.0 Feb 7, 2018
BREAKING CHANGE: although uncommon and unlikely, invalid construction was permissible in the past.  now, we eagerly throw.  this has a low but feasible  chance of breaking some existing installs/usages.
@cdaringe cdaringe force-pushed the cdaringe:feat/detect-knex-on-construction branch from 9e3ab74 to 4906279 Feb 7, 2018
Copy link
Contributor Author

@cdaringe cdaringe commented Feb 7, 2018

knex returns one of many dialect objects, of which there is no common base class/proto. therefore, a direct type check on the passed knex obj isn't an option. however, all dialects use the same client, which is a robust and easy assertion.

@ricardograca ricardograca merged commit 0c7b726 into bookshelf:master Feb 8, 2018
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Version 0.13.0 automation moved this from In Progress to Done Feb 8, 2018
Copy link

@ricardograca ricardograca commented Feb 8, 2018

Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants