Skip to content

Comparisons against UUIDs in postgres #13828

Closed

Description

@themobiusproject

Issue Creation Checklist

[x] I have read the contribution guidelines

Bug Description

SSCCE

Here is the link to the SSCCE for this issue:

What do you expect to happen?

SELECT count(*) AS "count" FROM "Foos" AS "Foo" WHERE "Foo"."uuid"::text LIKE '573b77ae%';

What is actually happening?

SELECT count(*) AS "count" FROM "Foos" AS "Foo" WHERE "Foo"."uuid" LIKE '573b77ae%';

Environment

  • Sequelize version: [email protected]
  • Node.js version: v14.17.6
  • If TypeScript related: TypeScript version: n/a

Bug Report Checklist

How does this problem relate to dialects?

  • I think this problem happens only for the following dialect(s): Postgres

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

  • Yes, I have the time but I don't know how to start, I would need guidance.

Activity

  1. added
    dialect: postgres
    type: feature
    on Dec 26, 2021
  2. ephys commented on Dec 28, 2021

    @ephys
    Member

    I suppose we could cast this automatically :)

    In the meantime you can cast it manually:

    await Foo.count({ 
      where: Sequelize.where(
        Sequelize.cast('uuid', 'text')
        Op.iLike,
        '573b77ae%'
      ),
    })

    let me know if it worked.

  3. self-assigned this
    on Dec 28, 2021
  4. added
    topic: operators
    on Oct 6, 2022
  5. ephys commented on Feb 25, 2023

    @ephys
    Member

    Following #15598, the cast syntax available on JSON paths will be available everywhere, so you can do this:

    await Foo.count({ 
      where: {
        'uuid::text': {
          [Op.iLike]: '573b77ae%'
        },
      },
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

dialect: postgrestopic: operatorstype: feature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions