ak4zh
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Ahhh gotcha...
25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Yes simply using inbuilt
jsonb
with node-postgres
everything works fine.25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Wish this
jsonb
issue was documented in bold letters in the docs haha...
Just curious why do you use postgres-js
adapter in your project if it has this issue?25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Ohhh shit...
Now I switched to
node-postgres
instead.
I thought it would be just an easy switch changing the import and creating the client.
But I see the return type of queries are different between both the adapters.
EDIT: This is for raw sql queries
node-postgres
returns .rows
postgres-js
returns rows directly.
So I guess I have to change all my queries as well. Seems like a lot of work.25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Figured out it was due to different postgres package:
postgres.js
results in data stored as string
node-postgres
stores the data correctly25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Also the column that is showing as json by studio but string by dbeaver when I try to run son jsonb based query I am getting error:
25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
It seems something is wrong with this method:
Ona another project I use inbuild
jsonb
column and the data is stored as actual json/array.
But this the above method I just realised the whole json is stored as a JSON.stringified version in the database.25 replies
DTDrizzle Team
•Created by ak4zh on 7/15/2024 in #help
Column name different in drizzle magic sql vs drizzle-orm
Ohh ok, primarily because I was finding it easier to just do raw sql.
Detail here:
https://discord.com/channels/1043890932593987624/1056966312997429278/1262240863560667138
I use a lot of raw sql query in my other project and was not aware about this behaviour as my column names were in same case.
4 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
I checked the official implementation of drizzle
jsonb
column already uses the JSON.parse
and JSON.stringify
so I should not have any performance drop vs using official jsonb
.
All good, thank you so much.25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Am I doing this right?
Will this slow my queries a lot as it's using
JSON.stringify
and JSON.parse
?
25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Turns out this does not work.
For now I am manually doing
new Date(dateColumnFromJsonb)
everytime I select
the rows.
Still looking for an convenient solution which I can configure in drizzle so it does the conversion automatically may be using custom column type25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
Thanks, this seems to do the trick:
Source:
https://github.com/colinhacks/zod/discussions/879#discussioncomment-2036276
25 replies
DTDrizzle Team
•Created by ak4zh on 7/13/2024 in #help
Infer date values in jsonb column as Date object
I already have this invoice schema with zod, I alsi use superform for forms so I have a dateProxy as well in place.
Will try the
transform
thing and report back
Currently I get this error in frontend
Error: Invalid ISO 8601 date string:
25 replies
DTDrizzle Team
•Created by Meexa on 12/7/2023 in #help
How to do "onConflictDoUpdate" when inserting an array of values?
I have a similar situation with composite unique index.
How can I use the index as the target?
I tried the above format:
But this results in an error:
I have verified that I am not passing any duplicate values in an array.
16 replies
DTDrizzle Team
•Created by ak4zh on 8/24/2023 in #help
adding default to array of text creates invalid migrations
6 replies
DTDrizzle Team
•Created by ak4zh on 8/24/2023 in #help
adding default to array of text creates invalid migrations
Sure
6 replies
DTDrizzle Team
•Created by ak4zh on 8/24/2023 in #help
adding default to array of text creates invalid migrations
Thanks, I did not get a chance to try this method as I already edited the SQL manually and migrated.
Just reporting so this can be improved.
6 replies
DTDrizzle Team
•Created by Noahh on 8/23/2023 in #help
Missing @opentelemetry/api module at runtime when upgrading to 0.28.4
Also I would like to know what is that
@opentelemetry/api
even doing in drizzle?55 replies
DTDrizzle Team
•Created by runonce on 5/21/2023 in #help
drizzle-kit drop config file does not exist
Got same issue
4 replies