Search no longer working

In my project, in most of my collections, Search is not working anymore. I get this :

[forest] 🌳🌳🌳  Unexpected error: enumValue.toLowerCase is not a function
{
  "stack": "TypeError: enumValue.toLowerCase is not a function\n
    at C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\dist\\services\\search-builder.js:205:25\n
    at arrayEach (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\node_modules\\lodash\\lodash.js:530:11)\n
    at Function.forEach (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\node_modules\\lodash\\lodash.js:9410:14)\n
    at C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\dist\\services\\search-builder.js:204:11\n   
    at arrayEach (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\node_modules\\lodash\\lodash.js:530:11)\n
    at Function.forEach (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\node_modules\\lodash\\lodash.js:9410:14)\n
    at SearchBuilder.perform (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\dist\\services\\search-builder.js:163:7)\n
    at SearchBuilder.performWithSmartFields (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\dist\\services\\search-builder.js:108:33)\n
    at QueryOptions.search (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\dist\\services\\query-options.js:212:16)\n
    at ResourcesGetter._buildQueryOptions (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\dist\\services\\resources-getter.js:94:24)\n
    at async ResourcesGetter.count (C:\\Users\\jvollant\\WebDev\\Syndic One Rebirth\\node_modules\\forest-express-sequelize\\dist\\services\\resources-getter.js:41:30)"
}

Hi @JeremyV ,

It seems you have a bad declaration of your enum values. Could you please share the value of your enum fields ?

For instance :

  const Places = sequelize.define('places', {
    displayName: {
      type: DataTypes.STRING,
      defaultValue: "",
      allowNull: false,
    },
    score: {
      type: DataTypes.INTEGER,
    },
    createdAt: {
      type: DataTypes.DATE,
    },
    updatedAt: {
      type: DataTypes.DATE,
    },
    numberOfLots: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
      allowNull: false,
    },
    numberOfBuildings: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
      allowNull: false,
    },
    sergicId: {
      type: DataTypes.INTEGER,
    },
    sergicUpdateTime: {
      type: DataTypes.DATE,
    },
    openReportCount: {
      type: DataTypes.INTEGER,
      defaultValue: 0,
      allowNull: false,
    },
    icsCode: {
      type: DataTypes.STRING,
    },
    pictureName: {
      type: DataTypes.STRING,
    },
    sergicOffer: {
      type: DataTypes.ENUM(['DIR', 'ESE', 'VSY']),
      defaultValue: "",
    },
    sergicIdFull: {
      type: DataTypes.STRING,
    },
    individualized: {
      type: DataTypes.BOOLEAN,
    },
    separated: {
      type: DataTypes.BOOLEAN,
    },
    temporary: {
      type: DataTypes.BOOLEAN,
      defaultValue: false,
    },
    inviteStatus: {
      type: DataTypes.BOOLEAN,
      defaultValue: false,
    },
    inviteUrl: {
      type: DataTypes.STRING,
    },
    wpCode: {
      type: DataTypes.STRING,
    },
    synchronizedWithSergicAt: {
      type: DataTypes.DATE,
    },
    fiscalYearMonth: {
      type: DataTypes.ENUM([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])
    },
    description: {
      type: DataTypes.STRING,
    },
    support247: {
      type: DataTypes.BOOLEAN,
      field: 'support_24_7',
      defaultValue: false,
    },
    workAdvance: {
      type: DataTypes.INTEGER,
    },
    firstRegulation: {
      type: DataTypes.DATE,
    },
    siret: {
      type: DataTypes.STRING,
    },
    serviceResidence: {
      type: DataTypes.BOOLEAN,
    },
    cooperativeSyndicate: {
      type: DataTypes.BOOLEAN,
    },
    principalSyndicate: {
      type: DataTypes.BOOLEAN,
    },
    constructionPeriod: {
      type: DataTypes.ENUM([
        'before_1949',
        'from_1949_to_1960',
        'from_1961_to_1974',
        'from_1975_to_1993',
        'from_1994_to_2000',
        'from_2001_to_2010',
        'after_2011',
        'unknown'
      ]),
    },
    canTalk: {
      type: DataTypes.BOOLEAN,
      defaultValue: true,
    },
    integrationState: {
      type: DataTypes.ENUM([
        'new',                          // Nouveau : Docs.en attente
        'awaiting_document_validation',	// Documents à valider
        'management_integration',	      // Intégration gestion
        'awaiting_budget_validation',	  // Attente validation budget
        'send_report',	                // Rattachement & PV à envoyer
        'invalid_budget',	              // Budget refusé à revoir
        'sage',	                        // Intégration Comptable - SAGE
        'awaiting_archives',            // Attente archives
        'done',                         // Actif
        'pending_lost',                 // Immeuble perdu à transférer
        'lost'                          // Immeuble perdu
      ]),
    },
    historicalMonument: {
      type: DataTypes.BOOLEAN,
    },
    loan: {
      type: DataTypes.BOOLEAN,
    },
    registrationNumber: {
      type: DataTypes.STRING,
    },
    kind: {
      type: DataTypes.ENUM([
        'habitation',
        'mixed',
        'asl',
        'parking',
        'commercial'
      ]),
    },
    orderPerilStartDate: {
      type: DataTypes.DATEONLY,
    },
    orderPerilEndDate: {
      type: DataTypes.DATEONLY,
    },
    dtg: {
      type: DataTypes.BOOLEAN,
    },
    dpe: {
      type: DataTypes.STRING,
    },
    generalMeetingDate: {
      type: DataTypes.DATEONLY,
    },
    difficulty: {
      type: DataTypes.BOOLEAN,
    },
    energyAudit: {
      type: DataTypes.BOOLEAN,
    },
    deletedAt: {
      type: DataTypes.BOOLEAN,
    },
    coownershipRegistrationDate: {
      type: DataTypes.DATE,
    },
  }, {
    tableName: 'places',
    underscored: true,
    schema: process.env.DATABASE_SCHEMA,
  });

Okey, your issue comes from this line. Could you try putting string instead :pray:. In the meantime, I’ll create an issue to fix that :wink:

Okay but this is really not convenient. This field is stored as an integer and I need to alias it (1=>‘January’ etc.)
Please keep me posted.

Wait if it’s an integer you should declare it as an integer. You can the on Forest Admin use it as an enum by updating the options “Alter Values” of the edit/display widget :wink:. You will have the same as simply using the enum like you did