CoursePark / KnexNest

A wrapper for Knex.js that can output list of objects hydrated from a select
76 stars 10 forks source link

Does not work with knex 0.8.0+ #1

Closed jurko-gospodnetic closed 9 years ago

jurko-gospodnetic commented 9 years ago

KnexNest uses some knex internals to deduce whether the given knex object is connected to a Postgres database, but that logic gets broken with knex version 0.8.0+.

Old logic was to check the given knex query like so:

knexQuery.client.Raw.name === 'Raw_PG'

However, with the knex 0.8.0 release the knexQuery.client.Raw property is no longer specialized for specific connection types and a different way of detecting Postgres connections must be used. One that works for knex 0.8.0+ releases, but does not for earlier ones, would be:

knexQuery.client.config.client === 'postgres'

Those two could be joined together to form a criteria that would correctly detect Postgres connections with all currently available knex releases like so:

        if (knexQuery.client.config
                ? knexQuery.client.config.client === 'postgres'
                : knexQuery.client.Raw.name === 'Raw_PG'
        ) {
dvalentiate commented 9 years ago

just released version 0.3.0 which should fix this issue