fix(knex): use driver name to identify client #3527
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
@feathers/knex
, when inserting data, use theclient.driverName
property to identify the clients that can return fields when inserting instead of the client config as a string.Problem
The current implementation of
@feathersjs/knex
expects the client to be passed as a string when initializing Knex. Example:However, a client can be passed as a class instance to Knex instead of a string. Example:
(The example is for using https://github.com/czeidler/knex-pglite)
When passing the client as an object,
@feathersjs/knex
throws an error because it cannot identify the client as a returning client (even though, in this example, the client is a derivative of thepg
client and is a returning client):The error happens at https://github.com/feathersjs/feathers/blob/dove/packages/knex/src/adapter.ts#L242
Solution
This PR fixes the issue by switching to
client.driverName
for identifying the client.client.driverName
is a string that contains the driver name:client.driverName
will have the same value asclient.config
(pg
,postgresql
, etc.)client.driverName
will have the name of the driver as a string