Skip to content
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

Add Date as a valid return type for max and min #1062

Merged
merged 24 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a228b57
Add `Date` as a valid return type for `max` and `min`
samclearman Jun 26, 2024
c861ead
Merge branch 'master' into patch-1
igalklebanov Jul 13, 2024
6fb4ce4
Merge branch 'master' into patch-1
igalklebanov Jul 14, 2024
ddb9597
`InferResult` should output plural. (#1064)
igalklebanov Jul 7, 2024
246bf58
Support update table1, table2, ... query support. Closes #192 (#1079)
koskimas Jul 14, 2024
9438f3b
Speedup types with huge databases. Fixes #867 (#1080)
koskimas Jul 19, 2024
c0cf9f1
add reusable helpers recipe and implement missing expression features…
koskimas Jul 22, 2024
4fb5378
feat: support refresh materialized view (#990)
QuentinJanuel Aug 2, 2024
c4461c4
Remove preventAwait (#1160)
wirekang Sep 29, 2024
bfc042f
ci: run 22.x
igalklebanov Oct 5, 2024
cddce81
add `ControlledTransaction`. (#962)
igalklebanov Oct 5, 2024
ad23622
`await using kysely = new Kysely()` support. (#1167)
igalklebanov Oct 19, 2024
44deb78
fix TS backwards compat following `ControlledTransaction`. (#1193)
igalklebanov Oct 24, 2024
a50e16c
chore: enforce min TS version (#1194)
igalklebanov Nov 4, 2024
b7155c1
fix package-lock.
igalklebanov Nov 24, 2024
7d293a7
fix jsdocs.
igalklebanov Dec 1, 2024
c937f1a
add `returning` support in `MERGE` queries. (#1171)
igalklebanov Dec 1, 2024
6be09d8
feat: add HandleEmtpyInListsPlugin. (#925)
austinwoon Dec 15, 2024
a0399c3
remove only.
igalklebanov Dec 21, 2024
7885c1f
Merge branch 'v0.28' into patch-1
igalklebanov Jan 5, 2025
db073df
Merge branch 'v0.28' into patch-1
igalklebanov Jan 5, 2025
a6caf96
add Date where missing, assume Date more common than string min/max.
igalklebanov Jan 5, 2025
b99b6a1
fix all tests.
igalklebanov Jan 5, 2025
12e8e83
remove created_at.
igalklebanov Jan 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/query-builder/function-module.ts
igalklebanov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -487,15 +487,20 @@ export interface FunctionModule<DB, TB extends keyof DB> {
* ```
*/
max<
O extends number | string | bigint | null = never,
O extends number | string | Date | bigint | null = never,
RE extends ReferenceExpression<DB, TB> = ReferenceExpression<DB, TB>,
>(
expr: RE,
): AggregateFunctionBuilder<
DB,
TB,
IsNever<O> extends true
? ExtractTypeFromReferenceExpression<DB, TB, RE, number | string | bigint>
? ExtractTypeFromReferenceExpression<
DB,
TB,
RE,
number | string | Date | bigint
>
: O
>

Expand Down Expand Up @@ -538,15 +543,20 @@ export interface FunctionModule<DB, TB extends keyof DB> {
* ```
*/
min<
O extends number | string | bigint | null = never,
O extends number | string | Date | bigint | null = never,
RE extends ReferenceExpression<DB, TB> = ReferenceExpression<DB, TB>,
>(
expr: RE,
): AggregateFunctionBuilder<
DB,
TB,
IsNever<O> extends true
? ExtractTypeFromReferenceExpression<DB, TB, RE, number | string | bigint>
? ExtractTypeFromReferenceExpression<
DB,
TB,
RE,
number | string | Date | bigint
>
: O
>

Expand Down
1 change: 0 additions & 1 deletion test/node/src/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
InsertResult,
SqliteDialect,
InsertQueryBuilder,
Logger,
Generated,
sql,
ColumnType,
Expand Down
4 changes: 2 additions & 2 deletions test/typings/test-d/aggregate-function.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,13 @@ async function testSelectWithDynamicReference(db: Kysely<Database>) {
expectNotAssignable<null>(result.count)
expectAssignable<bigint>(result.another_count)
expectNotAssignable<string | number | null>(result.another_count)
expectAssignable<string | number | bigint>(result.max)
expectAssignable<number | string | Date | bigint>(result.max)
expectNotAssignable<null>(result.max)
expectAssignable<number>(result.another_max)
expectNotAssignable<string | bigint>(result.another_max)
expectAssignable<number | null>(result.nullable_max)
expectNotAssignable<string | bigint>(result.nullable_max)
expectAssignable<string | number | bigint>(result.min)
expectAssignable<number | string | Date | bigint>(result.min)
expectNotAssignable<null>(result.min)
expectAssignable<string>(result.another_min)
expectNotAssignable<number | bigint | null>(result.another_min)
Expand Down
Loading