patrick
patrick
Explore posts from servers
DTDrizzle Team
Created by patrick on 10/18/2024 in #help
Rollup failed to resolve import vite-plugin-node-polyfills/shims/buffer from drizzle-orm/sqlite-core
I just started getting this error: drizzle-orgm: 0.35.2 vite-plugin-node-polyfills: 0.22.0 [vite]: Rollup failed to resolve import "vite-plugin-node-polyfills/shims/buffer" from "/tmp/seed/source/packages/core/node_modules/drizzle-orm/sqlite-core/columns/blob.js". it works locally, but fails when building in seed (via SST).
1 replies
DTDrizzle Team
Created by patrick on 7/23/2024 in #help
update multiple rows with uuid id's
I found a great post by @Andrew Sherman from 2023 describing how to construct a case/when for updating multiple rows in one update. My id's are uuid, and a simple translation of his example (which uses integer ids), fails with the dreaded "operator does not exist: uuid = character varying" error. i've tried adding cast ( as uuid) in several places and can't seem to find it. Here's the toSQL() of a simple single entry update... can anyone spot what i'm missing? Thanks! query { sql: 'update "shows" set "gross" = (case when "shows"."id" = :1 then :2 end) where "shows"."id" in (:3)', params: [ '397ac0a7-d8e3-4a2e-8dcf-789ee99638a5', 1, '397ac0a7-d8e3-4a2e-8dcf-789ee99638a5' ] }
3 replies
DTDrizzle Team
Created by patrick on 5/23/2024 in #help
I made a change, yet generate says "No schema changes, nothing to migrate"
i added a column to a table balance: integer("balance") and drizzle-kit generate:pg generated the correct migration: ALTER TABLE "mytable" ADD COLUMN "balance" integer; then i went and backfilled in the values into the mytable since i really wanted it to be notNull(). then I came back and added .notNull(): balance: integer("balance").notNull() when I rerun drizzle-kit generate:pg it says "No schema changes, nothing to migrate" is this a bug? drizzle-kit 0.21.2
4 replies
DTDrizzle Team
Created by patrick on 2/5/2024 in #help
order by case clause possible?
No description
2 replies
TtRPC
Created by patrick on 10/27/2023 in #❓-help
cache craziness?
can someone sanity check something for me? i'm using sst + trpc + drizzleorm + aws + rds + postgres on the server, and i guess trpc + tanstack-query on the client side... when i do mutations, to say delete something from a list and go optimistically update the client state, via useUtils setData etc... everything is fine... then a few seconds later the browser does a request (tanstack query?) and gets OLD data back from "disk cache" and updates the view to how it was before my mutation! then a few seconds later it updates again with the correct data... i'm having a hard time figuring out which cacheing layer is screwing up... has anyone ever seen such behavior?
6 replies
TtRPC
Created by patrick on 9/8/2023 in #❓-help
query with no input reports error
No description
4 replies
DTDrizzle Team
Created by patrick on 9/6/2023 in #help
drizzle-kit failing with Top-level await is currently not supported with the "cjs" output format
Can't seem to get drizzle-kit generate to run? PS \sst\packages\core> node --version v18.17.1 PS \sst\packages\core> yarn drizzle-kit generate:pg yarn run v1.22.19 warning package.json: No license field $ \sst\node_modules.bin\drizzle-kit generate:pg drizzle-kit: v0.19.13 drizzle-orm: v0.28.5 No config path provided, using default 'drizzle.config.ts' Reading config file 'C:\git\triad\sst-triad\packages\core\drizzle.config.ts' Error: Transform failed with 1 error: C:\git\triad\sst-triad\node_modules\sst\node\util\index.js:15:21: ERROR: Top-level await is currently not supported with the "cjs" output format
6 replies
TtRPC
Created by patrick on 3/6/2023 in #❓-help
Is it possible to narrow an output schema if the query optionally doesn't return all fields?
I have a router procedure that has an input schema that has an optional filter that changes the shape of the data to only include those fields (like sql select), but those records will fail the output schema which contains all of the fields as required. is there a way to construct a .output() specification that narrows the type, possibly using z.partial() so that these partial "rows" will pass output validation?
40 replies
TtRPC
Created by patrick on 1/28/2023 in #❓-help
dynamic router creation
has anyone been able to create a dynamic router? e.g. i pass in the schema and some metadata and it produces the same routes but they are selected down to the metadata? my use case is i want to have crud against a set of tables... so i create a zod schema for each entity and want to create a router that does list, get, create, update, and delete, but for that one table, then i create one of each of these one per table... with what i've written, i'm getting the dreaded ts(2742) error.... The inferred type of 'routerForTable' cannot be named without a reference to '../../node_modules/@trpc/server/dist/core/parser.js'. This is likely not portable. A type annotation is necessary trying to pass in the schema as T extends z.ZodObject<z.ZodRawShape, z.UnknownKeysParam>
5 replies