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
adjustments for knex v1 and v2 #15
Conversation
there is a bunch of postgres tests failing after the knex upgrade, same as in Vincit#2353 |
knex v1+ changed the return values when `.returning()` clause is used (affecting postgres), before it returned array of primitive values if only 1 column was selected to be returned (e.g. `[1]` for `.returning('id')`) but now it always returns objects (e.g. `[{ id: 1 }]` for `.returning('id')`). Slightly reorganized `InsertOperation`, instead of calling `createModels` in `doExecute()` (right after `onRawResult` hook) and having "empty" model instances created there, possibly with undefined / declared default properties which would later overwrite input models in `InsertOperation.onAfter1`, offload the handling to `InsertOperation.onAfter1`, which now uses also `setDatabaseJson`, same as `createModels` function, to be consistent. Additionally, adjusted `$parseDatabaseJson` in `GraphInsert` integration tests, to only parse boolean values when they are present in `json`. related change in knex v1.0: knex/knex#4471
to make shapes of both querybuilders as close to each other as possible. Most of the methods were introduced in knex v1. - `fromRaw` - `whereLike` - `andWhereLike` - `orWhereLike` - `whereILike` - `andWhereILike` - `orWhereILike` - `withMaterialized` - `withNotMaterialized` - `jsonExtract` - `jsonSet` - `jsonInsert` - `jsonRemove` - `whereJsonObject` - `orWhereJsonObject` - `andWhereJsonObject` - `whereNotJsonObject` - `orWhereNotJsonObject` - `andWhereNotJsonObject` - `whereJsonPath` - `orWhereJsonPath` - `andWhereJsonPath` and one new `JoinBuilder` method - `andOnJsonPathEquals` (referencing knex's `JoinClause` method of the same name) `whereJson(Not)SupersetOf` / `whereJson(Not)SubsetOf` are now supported by knex >= 1.0, but for now objection handles them differently and only for postgres. Changing them to utilize knex methods directly may require a major version bump and upgrade guide. Added a test for checking JoinBuilder methods to be inline with knex's JoinClause. Fixed incorrect checking QueryBuilder methods if they are inline with knex's QueryBuilder. Added typings for new methods. Bumped knex `peerDependency` from `>=0.95.13` to `>=1.0.1` because of new methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahoy, Captain Code-Diver! 🏊♂️
Once again, you've plunged into the abyss of an external library to unearth a fix for an issue so exotic, it could have been featured on an episode of "Rare Code Mysteries"! 🕵️♂️🔍
Your unmatched dedication to addressing the needs of the niche-est of the niche users is truly commendable. As always, your valiant efforts shall be remembered in the hallowed halls of our git history. 🏆
So, with a mixture of amusement, awe, and a pinch of "do we really need this?", I approve this PR! 🎉
May your coding trident continue to pierce the depths of the unknown! ⚓️💻
adjustments for knex v1 and v2
knex v1+ changed the return values when
.returning()
clause is used (affecting postgres), before it returned array of primitive values if only 1 column was selected to be returned (e.g.[1]
for.returning('id')
) but now it always returns objects (e.g.[{ id: 1 }]
for.returning('id')
).Slightly reorganized
InsertOperation
, instead of callingcreateModels
indoExecute()
(right afteronRawResult
hook) and having "empty" model instances created there, possibly with undefined / declared default properties which would later overwrite input models inInsertOperation.onAfter1
, offload the handling toInsertOperation.onAfter1
, which now uses alsosetDatabaseJson
, same ascreateModels
function, to be consistent.Additionally, adjusted
$parseDatabaseJson
inGraphInsert
integration tests, to only parse boolean values when they are present injson
.related change in knex v1.0: knex/knex#4471
introduced new (or missing) knex querybuilder's methods
to make shapes of both querybuilders as close to each other as possible.
Most of the methods were introduced in knex v1.
fromRaw
whereLike
andWhereLike
orWhereLike
whereILike
andWhereILike
orWhereILike
withMaterialized
withNotMaterialized
jsonExtract
jsonSet
jsonInsert
jsonRemove
whereJsonObject
orWhereJsonObject
andWhereJsonObject
whereNotJsonObject
orWhereNotJsonObject
andWhereNotJsonObject
whereJsonPath
orWhereJsonPath
andWhereJsonPath
and one new
JoinBuilder
method -andOnJsonPathEquals
(referencing knex'sJoinClause
method of the same name)related: knex/knex#4859 knex/knex#5044
whereJson(Not)SupersetOf
/whereJson(Not)SubsetOf
are now supported by knex >= 1.0, but for nowobjection handles them differently and only for postgres.
Changing them to utilize knex methods directly may require a major version bump and upgrade guide.
Added a test for checking JoinBuilder methods to be inline with knex's JoinClause.
Fixed incorrect checking QueryBuilder methods if they are inline with knex's QueryBuilder.
Added typings for new methods.
Bumped knex
peerDependency
from>=0.95.13
to>=1.0.1
because of new methods.