Skip to content

Manager find method generating wrong queries #7247

@alvaroinckot

Description

@alvaroinckot

Issue Description

Different behavior from the connection manager find method and the repository find method.

The repository find method creates a query as expected with In clause, like:

manager.getRepository(Entity).find({ foo: In(['bar', 'derp']) })
SELECT * FROM entity WHERE foo IN ('bar','derp')

On the other hand, the manager find generates the following clause, like:

manager.find(Entity,{ where: { foo: In(['bar', 'derp']) }})
SELECT * FROM table WHERE foo = $1

Expected Behavior

manager.find(Entity,{ where: { foo: In(['bar', 'derp']) }})
generates

SELECT * FROM table WHERE foo = $1

instead of

SELECT * FROM entity WHERE foo IN ('bar','derp')

Actual Behavior

Described below.

// include the output in code tags like these!

Steps to Reproduce

// insert code here

My Environment

Dependency Version
Operating System MacOS X Catalina
Node.js version v12.16.1
Typescript version v4.0.5
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