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]: Condition with Date as input in sql template fails #2009

Closed
mpost opened this issue Mar 14, 2024 · 5 comments
Closed

[BUG]: Condition with Date as input in sql template fails #2009

mpost opened this issue Mar 14, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@mpost
Copy link

mpost commented Mar 14, 2024

What version of drizzle-orm are you using?

0.30.1

Describe the Bug

With a column

timestamp('createdAt', { mode: 'date', withTimezone: true }).notNull(),

using a where condition like

gte(sql`(${product.createdAt} AT TIME ZONE ${timeZone})`, date)

we see the following error:

TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received an instance of Date

Changing the the timestamp mode to string or date has not effect.

The only workaround is to convert the date to string when inserting in the where condition:

gte(sql`(${product.createdAt} AT TIME ZONE ${timeZone})`, date.toISOString())

This issue did not occur in 0.29.3 and below.

Expected behavior

The Date object should be accepted as input in the where clause.

Environment & setup

Postgres

@mpost mpost added the bug Something isn't working label Mar 14, 2024
@abustany
Copy link

Duplicate of #1993 ?

@mpost
Copy link
Author

mpost commented Mar 19, 2024

Yes, possibly the same issue. This one is in a template string but sounds similar.

@L-Mario564
Copy link
Collaborator

Closing in favor of #2009.

@gp27
Copy link

gp27 commented Oct 19, 2024

Closing in favor of #2009.

This was the issue #2009 itself. It was likely meant to be closed in favor of issue #1993.

@L-Mario564
Copy link
Collaborator

This was the issue #2009 itself. It was likely meant to be closed in favor of issue #1993.

Correct. My bad.

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