Skip to content

feat(constructor): detect knex on construction#1756

Merged
ricardograca merged 1 commit into
bookshelf:masterfrom
cdaringe:feat/detect-knex-on-construction
Feb 8, 2018
Merged

feat(constructor): detect knex on construction#1756
ricardograca merged 1 commit into
bookshelf:masterfrom
cdaringe:feat/detect-knex-on-construction

Conversation

@cdaringe

@cdaringe cdaringe commented Feb 6, 2018

Copy link
Copy Markdown
Contributor

Introduction

a bad knex arg is allowed on construction

Motivation

fail fast

Proposed solution

disallow a bad knex arg on construction

Comment thread src/bookshelf.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep. sorry i missed that.

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 feat/detect-knex-on-construction branch from 9e3ab74 to 4906279 Compare February 7, 2018 22:30
@cdaringe

cdaringe commented Feb 7, 2018

Copy link
Copy Markdown
Contributor Author

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
@ricardograca

Copy link
Copy Markdown
Member

Many thanks!

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants