Subquery with date: No overload matches this call
See original GitHub issueHi, I need help once more… I’m trying to create a subquery with a datetime column.
This is the table definition:
export const tMessage = new class TMessage extends Table<DBConnection, 'TMessage'> {
public uid = this.autogeneratedPrimaryKey<u64>('uid', 'custom', CUSTOM_TYPES.UID_MESSAGE);
public processedAt = this.column('processedAt', 'localDateTime');
}
I want to select all messages, where the processedAt
is smaller or equal to the processedAt
of a message with a certain uid
.
this._db
.selectFrom(tMessage)
.select({
uid: tMessage.uid,
processedAt: tMessage.processedAt,
})
.where(
tMessage.processedAt.lessOrEquals(
// Subquery
this._db
.selectFrom(tMessage)
.where(tMessage.uid.equals(referenceUid))
.selectOneColumn(tMessage.processedAt),
),
)
.orderBy('processedAt', 'asc')
.limit(limit)
.executeSelectMany()
However, this fails:
No overload matches this call.
...
Argument of type 'GroupByOrderByExecutableSelectExpression<DB<"DBConnection">, TMessage, undefined, Date, NoTableOrViewRequiredView<DB<"DBConnection">>, "result">' is not assignable to parameter of type 'Date'.
Argument of type 'GroupByOrderByExecutableSelectExpression<DB<"DBConnection">, TMessage, undefined, Date, NoTableOrViewRequiredView<DB<"DBConnection">>, "result">' is not assignable to parameter of type 'IComparableValueSource<TableOrViewRef<DB<"DBConnection">>, Date>'.
Argument of type 'GroupByOrderByExecutableSelectExpression<DB<"DBConnection">, TMessage, undefined, Date, NoTableOrViewRequiredView<DB<"DBConnection">>, "result">' is not assignable to parameter of type 'IComparableValueSource<TableOrViewRef<DB<"DBConnection">>, Date | null | undefined>'.
Is this because the subquery may return undefined, and undefined cannot be compared to a Date
column?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Error No overload matches this call TS2769 - Stack Overflow
Depends on what you want date to be if res.date is undefined. A possibility might be date: res && res.date && new Date(res.date)....
Read more >4 beta, useQuery No overload matches this call. #3502 - GitHub
Describe the bug Type error: No overload matches this call. Overload 1 of 3, '(queryKey: QueryKey, options?
Read more >CALL {} (subquery) - Cypher Manual - Neo4j
The `+CALL {}+` clause evaluates a subquery that returns some values. ... a RETURN statement are called returning subqueries while subqueries without such...
Read more >No overload matches this call error in TypeScript | bobbyhadz
The error "No overload matches this call" occurs when we call a function and pass it a parameter that doesn't match any of...
Read more >Scalar Expressions | CockroachDB Docs
In most cases, conditions and result expressions after the first match are not evaluated. The exception is subqueries, which are eagerly evaluated when ......
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
I’m making this test:
It works on Sqlite, I’m so surprised, I didn’t expect it 😄; that is not clearly documented in the sqlite documentation. I’m going to continue investigating if all other databases have the same feature. For sure this case must be in the library.
Regarding the case you describes, you can use a left join.
If you want to get all messages only if the
referenceUid
exists the previous query is valid for you (I updated because I used the wrong join):But if you want to get all the messages in the case of the
referenceUid
doesn’t exists this can works for you:Great, thank you @juanluispaz!