drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
24.25k stars 621 forks source link

[BUG]: Conditional Operators on Dates (Bun & SQLite) #1034

Open mountainash opened 1 year ago

mountainash commented 1 year ago

What version of drizzle-orm are you using?

0.27.2

What version of drizzle-kit are you using?

No response

Describe the Bug

Filtering gt, lt or between on dates [with SQLite] doesn't return expected results.

I've created an isolated example to show (and play with this) at https://codesandbox.io/p/sandbox/drizzle-dates-d4yqmk

See the README.md for instructions on seeding and running. See index.ts for the script and to uncomment the various where conditions.

.where(gt(transactions.date, new Date("2015"))) returns

[
  {
    "date": 2015-11-19T19:23:26.000Z,
    "price": 1
  }, {
    "date": 2016-07-19T02:48:39.000Z,
    "price": 991
  }, {
    "date": 2013-02-25T19:40:01.000Z,
    "price": 696
  }, {
    "date": 2017-10-01T13:57:38.000Z,
    "price": 186
  }, {
    "date": 2011-06-16T17:09:13.000Z,
    "price": 173
  }
]

Expected behavior

Expect the row returned to match the where condition when used with a Date.

From the example above, I'd expect the results to be limited to:

[
  {
    "date": 2016-07-19T02:48:39.000Z,
    "price": 991
  }, {
    "date": 2017-10-01T13:57:38.000Z,
    "price": 186
  }
]

Environment & setup

fre2mansur commented 4 months ago

still not fixed?