valtyr/prisma-kysely

[BUG] Implicit join table key type could be in the wrong order

Closed this issue · 0 comments

Hi, I probably founded a minor bug for implicit join table type.
Version: 1.7.1

Here is a sample schema that has 2 models that joined m-n way.

model Shop {
    id         Int        @id @default(autoincrement())
    name       String
    categories Category[]
}

model Category {
    name  String @id
    shops Shop[]
}

In this case, the following is correctly created, which corresponds to the actual created table.

export type CategoryToShop = {
  A: string;
  B: number;
};

[Bug case]
On the other hand, if I name the join field from "shops" to "businesses",

model Shop {
    id         Int        @id @default(autoincrement())
    name       String
    categories Category[]
}

model Category {
    name       String @id
    businesses Shop[]
}

Types of A and B become opposite, which doesn't match with the actual table.

export type CategoryToShop = {
  A: number;
  B: string;
};