Can't Filter subtable using date gt: I'm trying t...
# orm-help
c
Can't Filter subtable using date gt: I'm trying to filter records where an invoice date is greater than a horizon date. I get records back, but some of the vendors have invoice dates dating before the horizon (and none after). In other areas, I'm using filters on subtables, but none where the date can be used as a filter. where clause:
Copy code
const whereClause = {
      AND: [
        {
          InvoiceTransaction: {
            some: {
              InvoiceDate: { gt: horizon }
            }
          }
        },
        {
      ...(searchString?
          {
            VendorName: { contains: searchString },
          }
      : {}),
        }
      ]
    }
The schema
Copy code
model Vendor {
  VendorPKID          Int      @id @default(autoincrement())
  VendorUno           Int      @unique
  VendorNumber        Int?
  VendorID            String?  @db.VarChar(10)
  VendorName          String?  @db.VarChar(40)
  NameUno             Int?
  VendorTypeCode      String?  @db.VarChar(5)
  AddressUno          Int?
  Address1            String?  @db.VarChar(60)
  Address2            String?  @db.VarChar(60)
  City                String?  @db.VarChar(60)
  State               String?  @db.VarChar(5)
  PostalCode          String?  @db.VarChar(50)
  Note                String?  @db.VarChar(Max)
  Active              Boolean  @default(false)
  ActiveFromDate      DateTime @db.Date
  ModifiedDate        DateTime @default(now()) @db.DateTime
  ModifiedBy          String   @db.VarChar(30)

  InvoiceTransaction  InvoiceTransaction[]
}
Setting horizon to: 2020-01-11T000000.000Z or 2015-01-11T000000.000Z makes no difference. Both return the same records
I cannot filter on InvoiceTransaction using the InvoiceDate and a searchString This does NOT return different results based on the horizon.
Copy code
const whereClause = {
      AND: [
        {
          InvoiceDate: { gt: horizon }
        },
        {
          ...(searchString?
            {
              CombinedNarrative: { contains: searchString }
            }
        : {})
        }
      ]

    }
FIXED - it was an issue with the how the parameter was being fed into the function.