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]:timestamp being transformed wrongly with bun:sql #4156

Open
1 task done
eslym opened this issue Feb 21, 2025 · 0 comments
Open
1 task done

[BUG]:timestamp being transformed wrongly with bun:sql #4156

eslym opened this issue Feb 21, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@eslym
Copy link

eslym commented Feb 21, 2025

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.39.3

What version of drizzle-kit are you using?

0.30.4

Other packages

[email protected]

Describe the Bug

bun:sql return timestamp as Date natively, so the following line create problem

return new Date(this.withTimezone ? value : value + '+0000');

it resulting new Date("${Date}+000") which would become something like new Date("Fri Feb 21 2025 01:52:26 GMT+0000 (Coordinated Universal Time)+000"), it would still able to be parsed into Date but the precision will lost.

I have to make the following helper function to ensure date is retrieved correctly

export function precise_date(src: SQL | SQLWrapper) {
    return sql`(${src})::text`.mapWith((d) => new Date(d));
}

db.select({ createdAt: precise_date(table.createdAt) })
@eslym eslym added the bug Something isn't working label Feb 21, 2025
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

1 participant