Skip to content

[Postgres]: Where clause issue #211

Closed

Description

@dcworldwide

I have a Select Where In query that isn't working with query builder.

I'm stuck, not sure what i'm doing wrong.. It may be a bug or simply my mistake. Would really appreciate some help.

            .createQueryBuilder("ac")
            .where("ac.sId = :sId", { sId })
            .andWhere("ac.code IN (:codes)", { codes: codes.join(",") })
            .getOne();

It translates to SQL...

SELECT "ac"."sId" AS "ac_sId", "ac"."code" AS "ac_code" FROM "table" "ac" WHERE "ac"."code" IN   ($1) -- PARAMETERS: ["treci"]

But no results return.

I copied and pasted the SQL in Pgadmin and ran it and it failed. But...once I changed "ac"."code" IN ("treci") to "ac"."code" IN ('treci') it worked.

Is there a quote issue?

Activity

  1. changed the title [-][Postgres]: Where In Query Issue[/-] [+][Postgres]: Where clause issue[/+] on Jan 17, 2017
  2. added a commit that references this issue on Jan 17, 2017
  3. pleerock commented on Jan 17, 2017

    @pleerock
    Member

    What was the issue?

  4. dcworldwide commented on Jan 17, 2017

    @dcworldwide
    ContributorAuthor

    I made a silly mistake with my async test logic, was trying to read a record that didn't exist. 🤦‍♂️

  5. pleerock commented on Jan 17, 2017

    @pleerock
    Member

    in your code btw, instead of { codes: codes.join(",") } you should just do { codes: codes }

  6. dcworldwide commented on Jan 17, 2017

    @dcworldwide
    ContributorAuthor

    Thanks. That's neat. I didnt see an example in the docs for where in queries.

  7. added a commit that references this issue on Mar 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions