An open API service indexing awesome lists of open source software.

https://github.com/samchon/prisma-bug-undefined-join-bug


https://github.com/samchon/prisma-bug-undefined-join-bug

Last synced: over 1 year ago
JSON representation

Awesome Lists containing this project

README

          

Error reproducing repo for Prisma.

When `undefined` value be assigned in `include` option, `Prisma` can't distinguish the `undefined` value, and just perform join operation. Therefore, when conditional join is required, manual `delete` operation be required, and it seems inconvenient and ridiculous.

```typescript
const read = (prisma: PrismaClient) =>
(joinFiles: boolean) =>
async (id: string) => {
const article = await prisma.bbs_articles.findFirstOrThrow({
where: { id },
include: {
files: joinFiles
? { include: { file: {} } }
: undefined,
},
});
console.log({
joinFiles,
expectedBehavior: joinFiles === !!article.files?.length,
files: article.files,
});
};

read(prisma)(false)("some-bbs-article-id");
```

> ```bash
> {
> joinFiles: false,
> expectedBehavior: false,
> files: [
> {
> id: '608b855c-8728-479c-8105-2594052c84c1',
> bbs_article_id: 'f1f89022-d872-4bb4-b429-cace6b2f153a',
> attachment_file_id: 'd6779072-24a2-4424-bc56-4db501671202',
> sequence: 0
> }
> ]
> }
> ```