Search on collection is sending an error - "function lower(uuid) does not exist"

Expected behavior

I should be able to search for records on my collection.

Actual behavior

Searching is sending an error

What is the current behavior?

Failure Logs

On server logs:
[forest] 🌳🌳🌳 Unexpected error: function lower(uuid) does not exist

On the admin frontend:

Here is the model in /models/countries.js

 const Countries = sequelize.define('countries', {
    id: {
      type: DataTypes.STRING,
      primaryKey: true,
    },
    createdAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('now()'),
    },
    updatedAt: {
      type: DataTypes.DATE,
      defaultValue: Sequelize.literal('now()'),
    },
    name: {
      type: DataTypes.STRING,
    },
    iso2: {
      type: DataTypes.STRING,
    },
    iso3: {
      type: DataTypes.STRING,
    },
    active: {
      type: DataTypes.BOOLEAN,
    },
    matchRate: {
      type: DataTypes.INTEGER,
    },
    matchRateDob: {
      type: DataTypes.INTEGER,
      field: 'matchRateDOB',
    },
    photoIdRequired: {
      type: DataTypes.BOOLEAN,
      defaultValue: true,
    },
  }, {
    tableName: 'countries',
    schema: process.env.DATABASE_SCHEMA,
  });

Hi @Patoche, thanks for joining our community!

The problem seems to be related to a bad generation/definition of your ID field.

Do you confirm that you’re using UUID as primaryKey on your countries table?

Yes. Here is the CREATE statement of this table:

CREATE TABLE public.countries
(
    id uuid NOT NULL DEFAULT uuid_generate_v4(),
    "createdAt" timestamp without time zone NOT NULL DEFAULT now(),
    "updatedAt" timestamp without time zone NOT NULL DEFAULT now(),
    name character varying COLLATE pg_catalog."default" NOT NULL,
    iso2 character varying(2) COLLATE pg_catalog."default" NOT NULL,
    iso3 character varying(3) COLLATE pg_catalog."default" NOT NULL,
    active boolean NOT NULL,
    "matchRate" smallint NOT NULL,
    "matchRateDOB" smallint NOT NULL,
    "photoIdRequired" boolean NOT NULL DEFAULT true,
    CONSTRAINT "PK_b6a3cb6e0aec5598934117aede9" PRIMARY KEY (id)
)

Thanks for sharing this.

Can you try to define your id field as follow:

    id: {
      type: DataTypes.UUID,
      primaryKey: true,
      defaultValue: Sequelize.literal('uuid_generate_v4()'),
    },

Awesome that works! Thanks