-
-
Notifications
You must be signed in to change notification settings - Fork 700
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(#1113): postgres parse date value from string or date object #3143
base: main
Are you sure you want to change the base?
Conversation
when will this request merge? |
This issue is a major blocker, I can confirm that this change fixes this issue. Not sure about any side-effects or edge cases.
diff --git a/node_modules/drizzle-orm/pg-core/columns/timestamp.cjs b/node_modules/drizzle-orm/pg-core/columns/timestamp.cjs
index f558f6c..32185fa 100644
--- a/node_modules/drizzle-orm/pg-core/columns/timestamp.cjs
+++ b/node_modules/drizzle-orm/pg-core/columns/timestamp.cjs
@@ -58,7 +58,7 @@ class PgTimestamp extends import_common.PgColumn {
return new Date(this.withTimezone ? value : value + "+0000");
};
mapToDriverValue = (value) => {
- return value.toISOString();
+ return new Date(value).toISOString();
};
}
class PgTimestampStringBuilder extends import_date_common.PgDateColumnBaseBuilder {
diff --git a/node_modules/drizzle-orm/pg-core/columns/timestamp.js b/node_modules/drizzle-orm/pg-core/columns/timestamp.js
index 5f793f0..b455b04 100644
--- a/node_modules/drizzle-orm/pg-core/columns/timestamp.js
+++ b/node_modules/drizzle-orm/pg-core/columns/timestamp.js
@@ -31,7 +31,7 @@ class PgTimestamp extends PgColumn {
return new Date(this.withTimezone ? value : value + "+0000");
};
mapToDriverValue = (value) => {
- return value.toISOString();
+ return new Date(value).toISOString();
};
}
class PgTimestampStringBuilder extends PgDateColumnBaseBuilder {
|
Its a major blocker .. |
This diff should work, but we need to adapt the types too, because when I run this patch, I am seeing issues with the drizzle-zod schema validation. Not sure how much related this is w.r.t. to this PR. |
Will this be patched into the other cores as well? I'm seeing a similar issue with mysql. |
#1113 since this issue is still open and i recently started using pglite with electron i got this issue.
fixed it by just returning a new date that allows a Date and a string argument without changing much.