volks
volks
Explore posts from servers
DTDrizzle Team
Created by volks on 5/29/2023 in #help
Postgres's Serial column type doesn't automatically have a default
6 replies
DTDrizzle Team
Created by arekmaz on 5/14/2023 in #help
weird ilike postgres behavior
Enable logging in drizzle and view the raw sql query that it executes, then you can see whether or not its correct
4 replies
DTDrizzle Team
Created by volks on 5/13/2023 in #help
Self referencing nullable ID field not assigneable in a `eq` statement
Which is resulting in
typescript: No overload matches this call.
Overload 1 of 2, '(left: Aliased<string | null>, right: string | Placeholder<string, any> | SQLWrapper | AnyColumn | null): SQL<unknown>', gave the following error.
Argument of type 'PgUUID<{ tableName: "carrier_tasks"; data: string; name: "id"; driverParam: string; notNull: true; hasDefault: true; }>' is not assignable to parameter of type 'Aliased<string | null>'.
Type 'PgUUID<{ tableName: "carrier_tasks"; data: string; name: "id"; driverParam: string; notNull: true; hasDefault: true; }>' is missing the following properties from type 'Aliased<string | null>': sql, fieldAlias, getSQL
Overload 2 of 2, '(left: PgUUID<{ tableName: "carrier_tasks"; data: string; name: "id"; driverParam: string; notNull: true; hasDefault: true; }>, right: string | Placeholder<string, any> | SQLWrapper | AnyColumn): SQL<...>', gave the following error.
Argument of type 'string | null' is not assignable to parameter of type 'string | Placeholder<string, any> | SQLWrapper | AnyColumn'.
Type 'null' is not assignable to type 'string | Placeholder<string, any> | SQLWrapper | AnyColumn'.
typescript: No overload matches this call.
Overload 1 of 2, '(left: Aliased<string | null>, right: string | Placeholder<string, any> | SQLWrapper | AnyColumn | null): SQL<unknown>', gave the following error.
Argument of type 'PgUUID<{ tableName: "carrier_tasks"; data: string; name: "id"; driverParam: string; notNull: true; hasDefault: true; }>' is not assignable to parameter of type 'Aliased<string | null>'.
Type 'PgUUID<{ tableName: "carrier_tasks"; data: string; name: "id"; driverParam: string; notNull: true; hasDefault: true; }>' is missing the following properties from type 'Aliased<string | null>': sql, fieldAlias, getSQL
Overload 2 of 2, '(left: PgUUID<{ tableName: "carrier_tasks"; data: string; name: "id"; driverParam: string; notNull: true; hasDefault: true; }>, right: string | Placeholder<string, any> | SQLWrapper | AnyColumn): SQL<...>', gave the following error.
Argument of type 'string | null' is not assignable to parameter of type 'string | Placeholder<string, any> | SQLWrapper | AnyColumn'.
Type 'null' is not assignable to type 'string | Placeholder<string, any> | SQLWrapper | AnyColumn'.
Since currentTask.nextTaskId is of type string | null . There are easy workarounds but this doesn't seem like the appropriate behavior
2 replies
DTDrizzle Team
Created by volks on 5/10/2023 in #help
Raw sql nullable types, sql<Type | undefined>
9 replies
DTDrizzle Team
Created by volks on 5/10/2023 in #help
Raw sql nullable types, sql<Type | undefined>
Will you create an issue on GH if this warrants one? I would like to follow it
9 replies
DTDrizzle Team
Created by volks on 5/10/2023 in #help
Raw sql nullable types, sql<Type | undefined>
Yeah quite a niche situation, glad I caught it. Thanks @Dan Kochetov
9 replies
DTDrizzle Team
Created by Cory on 5/10/2023 in #help
Type error for eq()
Good catch, you're getting the expected 1 argument but got 2 for the .where
4 replies
DTDrizzle Team
Created by volks on 5/10/2023 in #help
Raw sql nullable types, sql<Type | undefined>
Sorry, mistook the issue a bit, it seems that without the .mapWith() its inferred properly, but if its mapped then it is always non-nullable. Probably a niche situation but still a bit unusual, here's my whole thing
destination: sql<Point | null>`CASE WHEN driver_shifts.ride_id IS NOT NULL THEN active_rides.destination END`.mapWith(driverShifts.location),
destination: sql<Point | null>`CASE WHEN driver_shifts.ride_id IS NOT NULL THEN active_rides.destination END`.mapWith(driverShifts.location),
Type (property) destination: SQL<Point> But if I remove the mapWith It correctly is inferred to (property) destination: SQL<Point | null>
export const driverShifts = pgTable('driver_shifts', {
id: uuid('id').primaryKey().defaultRandom(),
createdAt: timestamp('created_at').defaultNow().notNull(),
location: pointDB("location").notNull(),
});
export const driverShifts = pgTable('driver_shifts', {
id: uuid('id').primaryKey().defaultRandom(),
createdAt: timestamp('created_at').defaultNow().notNull(),
location: pointDB("location").notNull(),
});
The pointDB is a custom PGColumn. But I don't think I can pass it to mapWith but rather I have to use a column from the table, this is a seperate question, don't think its related to the above problem
9 replies
DTDrizzle Team
Created by sevenwestonroads on 4/20/2023 in #help
How to reproduce a Prisma `include` statement for arrays of related entities without SQL?
@Noahh My usual approach for these complicated things is to first write it out in raw SQL and then translate that to Drizzle. Its much easier to reason with
21 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
It would be a great DX to be able to quickly get the fully qualified selector without having to hardcode it and lose on renames and other features
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
Any way to get fully qualified names to use with .raw eg console.log(driverShifts.id._.tableName + " " + driverShifts.id._.name) <- something like this, so I don't have to hardcode the string table_name.column_name The above example gives me error that I am accessing undefined field name TypeError: Cannot read properties of undefined (reading 'tableName') I am looking into writing utility function for this but this might be a common thing that I am missing
73 replies
DTDrizzle Team
Created by Thimo_o on 5/9/2023 in #help
Is drizzle fully framework agnostic?
Drizzle adds typesafety around already existing DB clients, Driver
node-postgres
postgres.js
NeonDB Serverless
AWS Data API Vercel Postgres
So whenever you can use these clients you can use Drizzle. And why NextJS is so popular is because their users like bleeding edge and typesafety (also influence from Theo). Library translates the Drizzle DSL into raw sql to be executed by the driver
4 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
I now understand the usage of raw... I was misusing it, thanks for the info
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
Won't the sql make the insides of the ${} parametized? Eg it will translate to something like st_astext($1) as $2?
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
@Dan Kochetov How can I type the sql.raw to properly be a number and not SQL<Unknown>?
task_count: sql.raw(`count(${carrierTask.id}) filter (where ${carrierTask.isCurrent} = false)`),
task_count: sql.raw(`count(${carrierTask.id}) filter (where ${carrierTask.isCurrent} = false)`),
73 replies
DTDrizzle Team
Created by SilentSean on 5/7/2023 in #help
Migration failure on fresh DB
Best to post your generated migration and the relevant schema file
9 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
mapWith works for me as well! Thanks, it's just a bit verbose. I would like to write a helper for this but I am unable to work with the string templating , as when I try to template with ${} it is translated as $1 and the placeholder $ arguments are not allowed in selects
export const selectPoint = (column: string, decoder: DriverValueMapper<any, any>) => {
return sql<Point>`st_astext(${column}) as ${column}`.mapWith(decoder);
};
export const selectPoint = (column: string, decoder: DriverValueMapper<any, any>) => {
return sql<Point>`st_astext(${column}) as ${column}`.mapWith(decoder);
};
backend-1 | [18:26:33 UTC] INFO: Query: select "employee_id", st_astext($1) as $2 from "active_carriers" -- params: ["location", "location"] Any ideas?
73 replies
DTDrizzle Team
Created by volks on 5/6/2023 in #help
Custom Type interpreted as String
Can we create an issue to track this? Might be useful?
73 replies