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

Deduplicated ColumnType type arguments are incorrect #203

Open
glacius-mitchell opened this issue Sep 18, 2024 · 1 comment
Open

Deduplicated ColumnType type arguments are incorrect #203

glacius-mitchell opened this issue Sep 18, 2024 · 1 comment

Comments

@glacius-mitchell
Copy link

glacius-mitchell commented Sep 18, 2024

I believe the ColumnType type argument deduplication logic in ad03d2e was incorrect.

In particular, it assumed an omitted update type would default to the insert type, when in fact Kysely's update type defaults to the select type (see https://github.com/kysely-org/kysely/blob/0.27.4/src/util/column-type.ts#L41).

This led to some regressions in the types generated by kysely-codegen.

For instance, where we previously had these generated types

export type Int8 = ColumnType<string, bigint | number | string, bigint | number | string>;

export type Timestamp = ColumnType<Date, Date | string, Date | string>;

which expanded to

type Int8 = {
    readonly __select__: string;
    readonly __insert__: string | number | bigint;
    readonly __update__: string | number | bigint;
}

type Timestamp = {
    readonly __select__: Date;
    readonly __insert__: string | Date;
    readonly __update__: string | Date;
}

we now have these generated types

export type Int8 = ColumnType<string, bigint | number | string>;

export type Timestamp = ColumnType<Date, Date | string>;

which expand to

type Int8 = {
    readonly __select__: string;
    readonly __insert__: string | number | bigint;
    readonly __update__: string;
}

type Timestamp = {
    readonly __select__: Date;
    readonly __insert__: string | Date;
    readonly __update__: Date;
}

The new column types are overly strict on what types of values can be specified for an update.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@glacius-mitchell
Copy link
Author

glacius-mitchell commented Sep 20, 2024

Hi @RobinBlomberg, I see you've already addressed this in e4f54f4. Is there any chance that commit will make its way into a release soon? We're unable to upgrade at the moment due to the type regressions above. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant