Failing types on "returning" methods
See original GitHub issueI recently updated to the latest version of knex and I faced what I think is one of the breaking changes from the release notes:
Changed data structure from RETURNING operation to be consistent with SELECT;
const ids = await knex.from("table").where(...).update({...}, "id");
used to return a string[]
but now returns a {id: string}[]
, fair enough.
However some of the overloads still reflect the previous behavior. I managed to fix it with patch-package with the following diff but I’m not 100% this is the correct solution.
Am I on the right track?
diff --git a/node_modules/knex/types/index.d.ts b/node_modules/knex/types/index.d.ts
index d9bf6e5..b50c579 100644
--- a/node_modules/knex/types/index.d.ts
+++ b/node_modules/knex/types/index.d.ts
@@ -692,7 +692,7 @@ export declare namespace Knex {
): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
insert<
TKey extends StrKey<ResolveTableType<TRecord>>,
- TResult2 = DeferredIndex.Augment<
+ TResult2 = DeferredKeySelection.Augment<
UnwrapArrayMember<TResult>,
ResolveTableType<TRecord>,
TKey
@@ -720,7 +720,7 @@ export declare namespace Knex {
): QueryBuilder<TRecord, TResult2>;
insert<
TKey extends string,
- TResult2 = DeferredIndex.Augment<
+ TResult2 = DeferredKeySelection.Augment<
UnwrapArrayMember<TResult>,
TRecord,
TKey
@@ -828,7 +828,7 @@ export declare namespace Knex {
update<
K1 extends StrKey<ResolveTableType<TRecord, 'update'>>,
K2 extends StrKey<ResolveTableType<TRecord>>,
- TResult2 = DeferredIndex.Augment<
+ TResult2 = DeferredKeySelection.Augment<
UnwrapArrayMember<TResult>,
ResolveTableType<TRecord>,
K2
@@ -870,7 +870,7 @@ export declare namespace Knex {
): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
update<
TKey extends StrKey<ResolveTableType<TRecord>>,
- TResult2 = DeferredIndex.Augment<
+ TResult2 = DeferredKeySelection.Augment<
UnwrapArrayMember<TResult>,
ResolveTableType<TRecord>,
TKey
@@ -925,7 +925,7 @@ export declare namespace Knex {
returning(column: '*', options?: DMLOptions): QueryBuilder<TRecord, DeferredKeySelection<TRecord, never>[]>;
returning<
TKey extends StrKey<ResolveTableType<TRecord>>,
- TResult2 = DeferredIndex.Augment<
+ TResult2 = DeferredKeySelection.Augment<
UnwrapArrayMember<TResult>,
ResolveTableType<TRecord>,
TKey
This issue body was partially generated by patch-package.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Return type method "Return value of the method is never used ...
I have to create a return type method takes String array as an argument and returns to int. So my method works completely...
Read more >Is it a bad idea to return different data types from a single ...
In a statically typed language I get why this is a bad idea. If every method returned Object (the common parent all classes...
Read more >Returning a Value from a Method (The Java™ Tutorials ...
The data type of the return value must match the method's declared return type; you can't return an integer value from a method...
Read more >return keyword in Java - GeeksforGeeks
In Java, return is a reserved keyword i.e, we can't use it as an identifier. It is used to exit from a method,...
Read more >Async return types (C#) - Microsoft Learn
Learn about the return types that async methods can have in C# ... Such unhandled exceptions are likely to cause your application to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Released in 1.0.4
@kibertoad Opened the PR on https://github.com/knex/knex/pull/5031