Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Find with exact DateTime input doesn't work with findMany or findOne #485

Closed
matthewmueller opened this issue Feb 13, 2020 · 2 comments
Closed
Assignees
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug. topic: types
Milestone

Comments

@matthewmueller
Copy link
Contributor

matthewmueller commented Feb 13, 2020

SQL

create table events (
  id serial not null primary key,
  "time" timestamp with time zone
);
insert into events ("time") values ('2018-09-04 00:00:00+00');

Query

client.events.findMany({ where: { time: new Date(Date.UTC(2018, 8, 4, 0, 0, 0, 0)) } })
// or 
client.events.findOne({ where: { time: new Date(Date.UTC(2018, 8, 4, 0, 0, 0, 0)) } })

Error

ConnectorError(ConnectorError { user_facing_error: None, kind: QueryError(Error { kind: ToSql(0), cause: Some(WrongType { postgres: Type(Timestamptz), rust: "chrono::naive::datetime::NaiveDateTime" }) }) })

Also doesn't work with gt, gte, lt, lte.

@matthewmueller matthewmueller added the process/candidate Candidate for next Milestone. label Feb 13, 2020
@pantharshit00 pantharshit00 added bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug. labels Feb 14, 2020
@divyenduz divyenduz added this to the Preview 23 milestone Feb 14, 2020
@divyenduz divyenduz removed the process/candidate Candidate for next Milestone. label Feb 18, 2020
@janpio janpio modified the milestones: Preview 23, Preview 24 Mar 3, 2020
@divyenduz divyenduz modified the milestones: Preview 24 Old, Preview 25 Mar 13, 2020
@janpio janpio changed the title Find with exact DateTime input doesn't work with findMany or find Find with exact DateTime input doesn't work with findMany or findOne Mar 19, 2020
@janpio
Copy link
Member

janpio commented Mar 19, 2020

I can not confirm these errors.

Script:

const { PrismaClient } = require('@prisma/client')

const prisma = new PrismaClient()

prisma.events.findMany({ where: { time: new Date(Date.UTC(2018, 8, 4, 0, 0, 0, 0)) } }).then(res => {
    console.log('findMany', res)
})

prisma.events.findOne({ where: { time: new Date(Date.UTC(2018, 8, 4, 0, 0, 0, 0)) } }).then(res => {
    console.log('findOne', res)
})

The findMany just works, and the fineOne returns another error as it seems one can not query with time:

Error:
Invalid `where: { time: new Date(Date.UTC(2018, 8, 4, 0, 0, 0, 0)) } }).then()` invocation in
C:\Users\Jan\Documents\throwaway\485\index.js:9:15

   5 prisma.events.findMany({ where: { time: new Date(Date.UTC(2018, 8, 4, 0, 0, 0, 0)) } }).then(res => {
   6     console.log('findMany', res)
   7 })
   8
→  9 prisma.events.findOne(


Invalid `prisma.events.findOne()` invocation:

{
  where: {
    time: new Date('2018-09-04T00:00:00.000Z')
    ~~~~
  }
}

Unknown arg `time` in where.time for type eventsWhereUniqueInput. Did you mean `id`? Available args:
type eventsWhereUniqueInput {
  id?: Int
}


    at Object.s [as events] (C:\Users\Jan\Documents\throwaway\485\node_modules\@prisma\client\runtime\index.js:1:46189)
    at Object.n.<computed> [as findOne] (C:\Users\Jan\Documents\throwaway\485\node_modules\@prisma\client\runtime\index.js:1:47572)
    at Object.<anonymous> (C:\Users\Jan\Documents\throwaway\485\index.js:9:15)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
    at internal/main/run_main_module.js:17:11

(The autocompletion also confirms this)

Is this correct?

@matthewmueller
Copy link
Contributor Author

matthewmueller commented Mar 19, 2020

Ahh, I re-tested this today in the integration tests and it's no longer an issue.

.findOne was wrong in this test, I needed to change it to .findMany since time is not unique.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug. topic: types
Projects
None yet
Development

No branches or pull requests

5 participants