Closed pavestru closed 5 months ago
Hey 👋
We do not have control over kysely-codegen
.
The column type should be ColumnType<string[], ..., ...>
and not ColumnType<string, ..., ...>[]
.
To reuse your definition, you can define it as follows:
type Int8Array = ColumnType<
SelectType<Int8>[],
InsertType<Int8>[],
UpdateType<Int8>[]
>
If the faulty plural type is a codegen output, should submit an issue there.
I have used kysely-codegen to generate the DB model. However, select statements do not return correct TS type corresponding to
int8[]
data type.Simplified example
TYPESCRIPT PLAYGROUND LINK
Consider the following schema (postgresql)
Given that this is the only table, the DB model generated by kysely-codegen would look like this (without any kysely-codegen customization):
Now, we have a function selecting the array:
Expected return type
Expected type returned by the query for column
some_column
should bestring[]
.Rationale:
some_column
is array ofInt8
. TypeInt8
is defined usingColumnType
, where the first generic parameter (for SELECT) is defined asstring
. That means that the returned type forsome_column
should bestring[]
.Actual return type
However, the select query returns type
Int8[]
forsome_column
, because there is no support for array ofColumnType
. In other words, ColumnType does not get "unwrapped" for array data type.TYPESCRIPT PLAYGROUND LINK