drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]: TS inference with multiple many-to-manys gets squashed

Open anthonyshew opened this issue 2 years ago • 0 comments

What version of drizzle-orm are you using?

0.26.5

What version of drizzle-kit are you using?

i hate drizzle-kit so N/A /s

Describe the Bug

Here's a Stackblitz!: https://stackblitz.com/edit/stackblitz-starters-5s6m8c?file=drizzle%2Ftest.ts

To reproduce:

  • If you go to line 6 of drizzle/test.ts and try to get autocomplete in the with property, you don't get any inference.
  • To get inference back, comment out lines 152 to 156 of drizzle/schema-test.ts.
  • Head back to line 6 of drizzle.test.ts and ask for autocomplete again. Boom, inference.

For extra confirmation, you'll also see the same behavior if you comment out lines 147 to 151 of drizzle/schema-test.ts instead of lines 152 to 156.

Disclaimers:

  • I haven't investigated to see if there are other related edge cases where inference can get dropped. For instance, I didn't check to see if the same thing happens with several one-to-ones or several one-to-manys.
  • I'm figuring this is a TS inference bug rather than a SQL limitation?

Thanks for taking a look Drizzlers. 🙏 Let me know if there's anything else I can do to provide context.

Expected behavior

Those sweet, sweet inferred types.

Environment & setup

Earth, I guess?

anthonyshew avatar Jun 03 '23 21:06 anthonyshew