Inherit knex instance VERSION property from constructor

This commit is contained in:
Kaarel Raspel 2016-05-19 23:48:24 +03:00
parent 46b686b4f0
commit 6cbceefdb8
2 changed files with 14 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import QueryInterface from '../query/methods';
import * as helpers from '../helpers';
import { assign } from 'lodash'
import BatchInsert from './batchInsert';
import Knex from "../index";
export default function makeKnex(client) {
@ -57,7 +58,7 @@ export default function makeKnex(client) {
// The `__knex__` is used if you need to duck-type check whether this
// is a knex builder, without a full on `instanceof` check.
knex.VERSION = knex.__knex__ = require('../../package.json').version;
knex.VERSION = knex.__knex__ = Knex.VERSION;
// Hook up the "knex" object as an EventEmitter.
const ee = new EventEmitter()

View File

@ -3,6 +3,18 @@
var knex = require('../../lib/index');
var test = require('tape')
test('it should have the same version as constructor has', function(t) {
t.plan(1)
var knexObj = knex({
database: 'dbname',
host: 'example.com',
password: 'password',
user: 'user'
})
t.equal(knexObj.VERSION, knex.VERSION)
knexObj.destroy()
})
test('it should parse the connection string', function(t) {
t.plan(1)
var knexObj = knex({