Skip to content
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

[BUG]:Unable to insert Date into Aws Postgres #1059

Closed
anasmohammed361 opened this issue Aug 15, 2023 · 3 comments
Closed

[BUG]:Unable to insert Date into Aws Postgres #1059

anasmohammed361 opened this issue Aug 15, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@anasmohammed361
Copy link

anasmohammed361 commented Aug 15, 2023

What version of drizzle-orm are you using?

^0.28.2

What version of drizzle-kit are you using?

^0.19.12

Describe the Bug

This is a simple schema

import {
  timestamp,
  pgTable
} from "drizzle-orm/pg-core";

export const test = pgTable("test",{
  date:timestamp("date",{mode:"date"}).notNull()
})

when i try to run this

async function main() {
  try {
    const res = await db.insert(test).values({
      date:new Date(),
    });
    console.log(res);
  } catch (error) {
    console.log(error);
  }
}
main() 

I get this error

BadRequestException: Cannot parse date or time "2023-08-15T19:57:42.417Z"
    at de_BadRequestExceptionRes (webpack-internal:///(rsc)/../node_modules/.pnpm/@aws-sdk+client-rds-data@3.388.0/node_modules/@aws-sdk/client-rds-data/dist-cjs/protocols/Aws_restJson1.js:485:23)
    at de_ExecuteStatementCommandError (webpack-internal:///(rsc)/../node_modules/.pnpm/@aws-sdk+client-rds-data@3.388.0/node_modules/@aws-sdk/client-rds-data/dist-cjs/protocols/Aws_restJson1.js:390:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async eval (webpack-internal:///(rsc)/../node_modules/.pnpm/@smithy+middleware-serde@2.0.3/node_modules/@smithy/middleware-serde/dist-cjs/deserializerMiddleware.js:9:32)
    at async eval (webpack-internal:///(rsc)/../node_modules/.pnpm/@aws-sdk+middleware-signing@3.387.0/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:15:28)
    at async eval (webpack-internal:///(rsc)/../node_modules/.pnpm/@smithy+middleware-retry@2.0.3/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:29:54)
    at async eval (webpack-internal:///(rsc)/../node_modules/.pnpm/@aws-sdk+middleware-logger@3.387.0/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:9:34)
    at async AwsDataApiPreparedQuery.values (webpack-internal:///(rsc)/../node_modules/.pnpm/drizzle-orm@0.28.2_@aws-sdk+client-rds-data@3.388.0/node_modules/drizzle-orm/aws-data-api/pg/index.mjs:135:28)
    at async AwsDataApiPreparedQuery.execute (webpack-internal:///(rsc)/../node_modules/.pnpm/drizzle-orm@0.28.2_@aws-sdk+client-rds-data@3.388.0/node_modules/drizzle-orm/aws-data-api/pg/index.mjs:117:22)
    at async main (webpack-internal:///(rsc)/./db/index.ts:24:21) {
  '$fault': 'client',
  '$metadata': {
    httpStatusCode: 400,
    requestId: 'be13c96b-e262-477a-b286-0ba48cbdcffe',
    extendedRequestId: undefined,
    cfId: undefined,
    attempts: 1,
    totalRetryDelay: 0
  }
}

I am unable to parse a JS Date Object into Postgres compatable TimeStamp object

Expected behavior

No response

Environment & setup

No response

@anasmohammed361 anasmohammed361 added the bug Something isn't working label Aug 15, 2023
@berenddeboer
Copy link

Having the same issue. We pass in the the proper javascript Date(), but it's not being passed correctly to RDS data.

@anasmohammed361
Copy link
Author

anasmohammed361 commented Aug 31, 2023

There is a workaround for now , but still might lose your querying capabilities

https://medium.com/@anasmohammed361/implement-next-auth-auth-js-with-drizzle-adapter-aws-rds-postgres-15a8d148ec99

@jakeleventhal
Copy link

This is most likely closed by #1659

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants