Nicolas
Explore posts from serversDTDrizzle Team
•Created by Nicolas on 8/11/2024 in #help
SQL string could not be parsed: non-terminated block comment at ...
Hi all,
I am using Turso and I added two properties to my users table
created_at
and updated_at
.
I successfully generated a migration file, which looks like this:
This is my schema:
When running the migration, i get the following error:
Any idea what's going on? This is a super simple migration, just adding 2 columns, so not sure what to do...
Thanks6 replies
DTDrizzle Team
•Created by Nicolas on 2/14/2024 in #help
Getting error NeonDbError when pushing migration file
Hi all,
So i have a schema that defines custom type JSON objects for my NeonDB database, like so:
And I am trying to use it like so:
However, I am getting an error
NeonDbError: data type json has no default operator class for access method "btree"
So perhaps I am not specifying the custom type of json
correctly, but I could not find any examples on the drizzle website.
I also tried like (commads instead of semi-colons):
But it still lead to the same error.
Any thoughts on how to do this properly?
Thank you!4 replies
DTDrizzle Team
•Created by Nicolas on 10/11/2023 in #help
Infer Types from Partial Select Prepared Statement
5 replies
DTDrizzle Team
•Created by Nicolas on 10/9/2023 in #help
Null fields not working as expected
Hi all,
I am using Drizzle ORM with Zod validation for useForm, and I am running into issues with fields that are allowed to be undefined / null, but I get Zod errors stating that the value of the optional fields (when left empty) are
invalid_type
and in required.
I was able to fix this by refining the field as follows:
This allows the city
field to be left blank, but by default, even though i didn't specify notNull()
on that field, Zod would error out saying that the field is required.
I am using Turso DB, so this is my schema:
Notice for all fields by the id
, organizationId
, and name
, they are optional; however, Zod treats them as ZodNullable
but they should in fact be treated as ZodOptional<ZodNullable<ZodString>>
to allow my fields to be empty (as is the intended affect).2 replies
DTDrizzle Team
•Created by Nicolas on 9/30/2023 in #help
notNull() is still letting field be optional
I am performing the following for SQLite:
However, when I perform:
export type NewProduct = typeof products.$inferInsert;
It says that id
is optional (this is what it shows when i hover over NewProduct
)
How can I fix this?8 replies
DTDrizzle Team
•Created by Nicolas on 9/30/2023 in #help
Explanation on execute() vs all() vs get() vs run()
I am using
prepare()
to make prepared statements for Turso (so SQLite), and the docs use prepare.all()
for SQLite instead of prepare.execute()
as is used for PostgreSQL and MySQL, why is that?
Same goes for prepare.get()
for SQLite instead of prepare.execute()
When do I know when to run those different queries for SQLite?
Thank you!1 replies
DTDrizzle Team
•Created by Nicolas on 9/29/2023 in #help
Issue Pushing Schema to Turso
Hi All,
I made a schema.ts with
sqliteTable
statements, and I created a drizzle.config.ts
as follows:
And when I try running pnpm drizzle-kit push:sqlite
, I get the following error regarding that it cannot find module better-sqlite3:
Am I not pushing the schema properly with the command drizzle-kit push:sqlite
?
Thank you!3 replies
DTDrizzle Team
•Created by Nicolas on 9/27/2023 in #help
How to make sql.placeholder() type safe
I have the following prepared statement:
However, when I use this like below:
const response = await listDeployments.execute({ orgId: input });
The orgId
is not type safe, I can enter whatever string I want, and there is no way to protect this call from receiving something other than orgId
Is there a way to make it such that the caller must pass in orgId
?
Thank you!4 replies
DTDrizzle Team
•Created by Nicolas on 9/23/2023 in #help
Neon and Drizzle ORM: Can my schema.ts create my tables in Neon?
As the title suggests, I was wondering if Drizzle ORM can create my tables in Neon from my schema.ts, or if I need to first create my tables in Neon with SQL, and then just create my schema.ts to reflect those tables.
Thank you!
7 replies