Nested Relations Where has Zero Typings :confused:
Hey guys - first post so please let me know if this isn't the wrong place or I'm doing something wrong. Anyhow, I'm trying to order a simple nested relation in a query:
Now - the with has no typings at all, so I have to hand craft the query with zero type annotations. There's also an issue of the
desc
binding element being implicitly of type any also, but that's for another day.
Has anybody come across this, and if so - is there a fix.. Or, more likely - am I doing something wrong, that isn't meant to be done this way?9 Replies
If you’re using
relations()
, have you exported them? Are all your tables using district names? (Those are two reasons I’ve seen for that)Here's my relation:
Regarding the exporting - I think so yes:
And when you pass
schema
to the drizzle
constructor, it includes those, right?It would appear so, yes
And used like so:
export const db = drizzle(sql, { schema });
Hm from what you’ve shown it looks correct. My assumption is that there’s something with the schema not configured correctly but I don’t see it here. Again I’d double check that all tables have unique names passed as the first argument, but otherwise I don’t have much to go off here.
I might suggest trying to put together a minimum reproduction, which may lead to building up to what the issue is - if you do it in stackblitz or such I could even poke at it myself
I'm rebuilding a single schema file to try that now. Wondering if splitting each table and relations into it's own file isn't helping matters.
If no joy though, I'll go create an example on stackblitz! Cheers for the help so far, will report back when I have something
Single file shouldnt matter as long as it winds up directly on the top level of the schema object
But easier to debug at least
yeah, single file didn't help 😦
Will make stackblitz tomorrow 🥱
Hey man - soo.. slightly frustrating: https://stackblitz.com/edit/stackblitz-starters-thhb1m?file=src%2Fexample.ts
However, it works 100% fine 😦
Even the type intersection
so.. even though the versions are the same for both orm and kit.. the typings are just nuked on my project
I am using sveltekit and a few other bits of tech, so maybe that's the issue as the tsconfig extends sveltekit one and other stuff 😢 Anyway - will report here once I've found the root cause in case anybody else ever finds this
Eughhhhhh
So I finally debugged the issue and it turned out to be the dumbest thing ever 😂
Another relation I had declared was referencing the wrong table..
Boy do I feel dumb now - what a nightmare trying to debug all that typescript 😂 Anyway, if anybody happens to come across the same thing, please check the relations closely as it's very easy to miss them when the tables are named similarly