NeonCop
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
we use this query as a subquery downstream in quite a few places so the drizzle is too deep, we'll worry about a rewrite when we get there (hopefully never!)
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
awesome thanks! big fan of drizzkle
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
what does TExcludedMethods do by the way? couldn't quite figure it out
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
what abstractions do you feel work better?
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
appreciate you looking through though!
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
ah yeah thats unfortunate
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
also realized I had some of the nullability map set to values that aren't nullable and not-null, but changing that doesn't help either
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
https://drizzle.run/c7jfxwp7k1k4afwgdspcvvo5
here you can see the type at the end does not satisfy the output, so I have to cast to unknown and then to the actual type. If I just let it infer the return type without declaring it, then it doesn't pick up on the fact that if you didn't pass in the join then that attribute won't be available
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
Thanks @Angelelz ! In my real code I actually do have the return type set as PgSelectBase, like this:
function buildMyQuery<T extends JoinOptions>({
params,
joins = {} as T,
}: {
params: MyQueryParams;
joins?: T;
}): PgSelectBase<
"base",
MyQuerySelection<T>,
"partial",
MyQueryNullabilityMap<T>
{// ... same implementation } But I still end up having to cast the query to that return type using (as unknown first) to make it work. The issue seems to be that once I start chaining conditional joins, TypeScript loses track of the relationship between the joins parameter and the final query type. Will have a drizzle.run example ready soon
27 replies
DTDrizzle Team
•Created by NeonCop on 11/28/2024 in #help
Types on conditional joins
Looked at https://discord.com/channels/1043890932593987624/1213991555271233637/1213991555271233637 and https://discord.com/channels/1043890932593987624/1128636955270324275 and neither had satisfactory answers. cc @Dan looks like you had some idea in the first thread?
27 replies
DTDrizzle Team
•Created by LeandroSGomes on 2/23/2024 in #help
How to make a select from "materialized_view" where clause
running into this
3 replies
DTDrizzle Team
•Created by Lloyd on 5/2/2024 in #help
Postgres.js type error string/date
apreciate you 😁
3 replies
DTDrizzle Team
•Created by terryball on 3/14/2024 in #help
Type error working with Postgres dates in v.0.30.1
@Angelelz
9 replies
DTDrizzle Team
•Created by terryball on 3/14/2024 in #help
Type error working with Postgres dates in v.0.30.1
seeing this too, even when I have the column in date mode, I get a typescript error if i have it as a iso string, and a runtime error if i leave it as a date. The between fix doesn't even work for me 😦
9 replies
DTDrizzle Team
•Created by francis on 9/4/2023 in #help
Drizzle join in a subquery results in ambiguous columns
my use case here is joining tables a and b which both have id field, and flatten the results in one table but not the other (so result is something like {id, field1FromA, field2fromA, b: {id, field1fromB}}). if i just execute that query, it correctly creates an object with that shape. But if I create a subquery called c, and then try to use c in a join (using c.id i.e. a.id), then it says ambiguous column because the underlying select selects it twice. This is probably some sort of nice runtime magic to nest objects but ends up messing up the sql downstream.
26 replies
DTDrizzle Team
•Created by francis on 9/4/2023 in #help
Drizzle join in a subquery results in ambiguous columns
+ 1
26 replies
DTDrizzle Team
•Created by JT on 2/11/2024 in #help
where has iterator gone?
any idea where this went? looking for a snippet foir a utils function for postgres that can help me use a generator for results even if it's just doing ab unch of queries in the back
5 replies
DTDrizzle Team
•Created by JT on 4/9/2023 in #help
Iterator for result set
any idea how to do this in postgres? can't quite seem to get the types right on thsi util function
10 replies
DTDrizzle Team
•Created by anthonyshew on 5/4/2023 in #help
Trying to write next-auth adapter
this is awesome work!!
81 replies