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

Array data types does not return the correct TS type #160

Open
caalberts opened this issue Jun 10, 2024 · 0 comments
Open

Array data types does not return the correct TS type #160

caalberts opened this issue Jun 10, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@caalberts
Copy link

caalberts commented Jun 10, 2024

Given the following schema:

CREATE table bookshelf(
  id bigserial NOT NULL,
  book_ids bigint[] NOT NULL);

The generated type is as follows:

export interface Bookshelf {
  id: Generated<Int8>
  book_ids: Int8[]
}

This type does not accept an array of numbers. The following code doesn't compile with Type number[] is not assignable to type Int8[]

await db
        .insertInto('bookshelf')
        .values({
          book_ids: [12, 23]
        })
        .execute()

However, if the array type is changed to the following as suggested in kysely-org/kysely#957 (comment), the same code compiles:

type Int8Array = ColumnType<
  SelectType<Int8>[],
  InsertType<Int8>[],
  UpdateType<Int8>[]
>;

export interface Bookshelf {
  id: Generated<Int8>
  book_ids: Int8Array
}

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
@RobinBlomberg RobinBlomberg added in progress We're working on it bug Something isn't working labels Aug 14, 2024
@RobinBlomberg RobinBlomberg removed the in progress We're working on it label Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants