adjustments for knex v1 and v2 #15
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.
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 callingcreateModelsindoExecute()(right afteronRawResulthook) 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 ascreateModelsfunction, to be consistent.Additionally, adjusted
$parseDatabaseJsoninGraphInsertintegration 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.
fromRawwhereLikeandWhereLikeorWhereLikewhereILikeandWhereILikeorWhereILikewithMaterializedwithNotMaterializedjsonExtractjsonSetjsonInsertjsonRemovewhereJsonObjectorWhereJsonObjectandWhereJsonObjectwhereNotJsonObjectorWhereNotJsonObjectandWhereNotJsonObjectwhereJsonPathorWhereJsonPathandWhereJsonPathand one new
JoinBuildermethod -andOnJsonPathEquals(referencing knex'sJoinClausemethod of the same name)related: knex/knex#4859 knex/knex#5044
whereJson(Not)SupersetOf/whereJson(Not)SubsetOfare 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
peerDependencyfrom>=0.95.13to>=1.0.1because of new methods.