Skip to content

Incorrect SQL expression if where parameter is empty array #9690

@PronDmytro

Description

@PronDmytro

Issue description

Incorrect SQL expression if where parameter is empty array

Expected Behavior

SQL expression should be:

SELECT "Foo"."id" AS "Foo_id" FROM "foo" "Foo"

Actual Behavior

Got Error:

query failed: SELECT "Foo"."id" AS "Foo_id" FROM "foo" "Foo" WHERE ()
error: error: syntax error at or near ")"

Steps to reproduce

reproduces with any entity

const repository = dataSource.getRepository(Foo)
await repository.find({
     where: [],
})

My Environment

Dependency Version
Operating System Windows 11 22H2
Node.js version 16.17.1
Typescript version 4.8.2
TypeORM version 0.3.11

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • 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.

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