Skip to content

find where clauses params order is wrong #7256

@Diluka

Description

@Diluka

Issue Description

here is a query like below

await OrderBill.find({
        where: {
          paidAt: Raw((alias) => `DATE(${alias}) = DATE(:date)`, { date: index.toDate() }),
          type: OrderBillType.HOSPITAL_FEE,
          isPaid: true,
        },
})

Expected Behavior

generate right params array (omit select)

SELECT *
FROM `mrcs_order_bill` `OrderBill`
WHERE DATE(`OrderBill`.`paidAt`) = DATE(?)
  AND `OrderBill`.`type` = ?
  AND `OrderBill`.`isPaid` = ? -- PARAMETERS: ["2020-12-31T16:00:00.000Z","HOSPITAL_FEE",true]

Actual Behavior

generate wrong params array (omit select)

SELECT *
FROM `mrcs_order_bill` `OrderBill`
WHERE DATE(`OrderBill`.`paidAt`) = DATE(?)
  AND `OrderBill`.`type` = ?
  AND `OrderBill`.`isPaid` = ? -- PARAMETERS: ["HOSPITAL_FEE",true,"2020-12-31T16:00:00.000Z"]

Steps to Reproduce

// insert code here

My Environment

Dependency Version
Operating System
Node.js version v12.20.0
Typescript version v4.1.3
TypeORM version v0.2.29

Additional Context

Relevant Database Driver(s)

  • aurora-data-api
  • aurora-data-api-pg
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time, and I know how to start.
  • Yes, I have the time, but I don't know how to start. I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions