Latest forest-express-sequelize breaks smart fields

Smart fields are broken in the latest version of forest-express-sequelize.

Expected behavior

I should be able to surface a smart field as a column.

Actual behavior

Sequelize throws an error that the smart field column doesn’t exist, when it shouldn’t be adding it to the query at all.

For some reason the smart field is being added to the actual query, which shouldn’t be happening.

After rolling back to forest-express-sequelize 6.3.6, everything is working again.

Context

Please provide any relevant information about your setup.

  • Package Version: 6.3.8
  • Express Version: ~4.17.1
  • Sequelize Version: ~5.21.13
  • Database Dialect: postgres
  • Database Version: 12.2
  • Project Name: Rupie

Hi @austinrupie :wave:

Thank you for your feedback! :pray:

I’ve just updated one of my projects with forest-express-sequelize@6.3.8 and I can’t find a way to reproduce your actual issue. I created a smart field with this code:

{
    field: 'fullname',
    type: 'String',
    get: (customer) => {
      return 'foo';
    }
  }

Then I browsed the Forest Admin UI, went to the collection table view, and everything seemed fine.

I may have missed something. Could you help me identify the problem: maybe you could provide a step by step way to reproduce the issue? (what kind of smart field, what action in the application generate the sequelize bug and what exact bug message do you see)?

1 Like

Ok, I just figured out the bug.

Our field is declared like:

  {
      field: 'fullName',
      type: 'String',
      get: user => ((user.firstName && user.lastName) ? (user.firstName + ' ' + user.lastName) : user.userName)
    },

see the camel casing?

Something in 3.3.7 was changed to make all fields lowercase.

If I change it to ‘fullname’ it works, but I want it to be camelcase still.

This breaks all of our camelcase smart fields.

Unexpected error: column User.fullName does not exist
SequelizeDatabaseError: column User.fullName does not exist

Hi @austinrupie :wave: I’ve just tested on

"forest-express-sequelize": "6.3.8",

And it work as expected with smart field named fullName.
image

Can you test with this new version please? Have you got any error on your server start?

Thanks!

How did you see this issue:
On table view?

  • If yes did you access the table by segment or filter?

On record details view?

Does the field appear as a smart field in collection settings?

Can you try to find in your .forestadmin-schema.json the declaration of your field?

 {
      "field": "fullName",
      "type": "String",
      "defaultValue": null,
      "enums": null,
      "integration": null,
      "isFilterable": false,
      "isReadOnly": true,
      "isRequired": false,
      "isSortable": false,
      "isVirtual": true,
      "reference": null,
      "inverseOf": null,
      "validations": []
 }

And see if isVirtual is set to true.

Oddly enough, “isVirtual” is indeed true.

{
      "field": "fullName",
      "type": "String",
      "defaultValue": null,
      "enums": null,
      "integration": null,
      "isFilterable": false,
      "isReadOnly": true,
      "isRequired": false,
      "isSortable": false,
      "isVirtual": true,
      "reference": null,
      "inverseOf": null,
      "validations": []
    }

but it still breaks.

It only seems to be a problem when I set the reference field.

Reference field When a user is referenced, I want to see the field…

All related table view tables suddenly break.

No errors on server start, same issue with 6.3.9

I do face the same issue. Collections with reference to smart fields are broken.

Hi @austinrupie, @Cyril_Limam,

We reproduced the issue thanks to your latest messages :pray:.
The team is currently working on a fix.

If you need a safe spot, you should definitively downgrade your forest-express-sequelize package version to 6.3.6.
We’ll let you know once a new patch version is available.

Thanks for your patience.

1 Like

@austinrupie we released the version 6.3.10 which contains the fix for your issue.

Can you try it on your project?

1 Like