# Cannot filter or use scope on Related Data

**URL:** <https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033>\
**Category:** Help me!\
**Created:** [August 2, 2021, 2:54pm UTC](https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033 "2021-08-02T14:54:12Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arda\_Yurdakul](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arda_yurdakul/32/2334_2.png) [@Arda\_Yurdakul](https://community.forestadmin.com/u/Arda_Yurdakul)\
**Post date:** [August 2, 2021, 2:54pm UTC](https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033/1 "2021-08-02T14:54:12Z")

</div>

Hi Forest,

I recently noticed that I am unable to use filters on related data. Incidentally, now that I have switched to v8, related data that has scopes applied also cause the same error. The issue stems from column names being camelCased instead of using underscores. This means I can use filters on a single worded column such as id but not others. Here’s the error log:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/6/68075744cdac267e31f5161b853302723a553491.png)  
It should say “active\_at” instead of “activeAt”. How can I fix this? Thank you.

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/forest/original/2X/2/2d3c124f3437d12385e75aa92211983fa3091f45.png)

---

<div class="post-metadata">

**Author:** ![anon34731316](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@anon34731316](https://community.forestadmin.com/u/anon34731316)\
**Post date:** [August 2, 2021, 5:30pm UTC](https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033/3 "2021-08-02T17:30:54Z")

</div>

Hello @Arda_Yurdakul,

Thanks for your message 🙌

I have an idea of what the problem could be here.  
Can you please tell me on what project this error occurred (its name)?  
And share the `sharePoints` model?

Thanks!

---

<div class="post-metadata">

**Author:** ![Arda\_Yurdakul](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arda_yurdakul/32/2334_2.png) [@Arda\_Yurdakul](https://community.forestadmin.com/u/Arda_Yurdakul)\
**Post date:** [August 2, 2021, 6:16pm UTC](https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033/4 "2021-08-02T18:16:23Z")

</div>

Hi,  
The project name is “monta-server-test” in package.json, but we changed it to “Monta Admin Panel” in Forest. I am sharing the chargePoints model here but the issue persists in **all tables**. I also should mention I am able to filter data with all columns without error in the regular table view. The issue is with **related data** Thank you.

> // This model was generated by Lumber. However, you remain in control of your models.  
> // Learn how here: [https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models](https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models)
> 
> module.exports = (sequelize, DataTypes) =\> {  
> const { Sequelize } = sequelize;  
> // This section contains the fields of your model, mapped to your table’s columns.
> 
> // Learn more here: [Enrich your models - Developer Guide](https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model)  
> const ChargePoints = sequelize.define(‘chargePoints’, {  
> externalId: {  
> type: DataTypes.STRING,  
> field: ‘external\_id’,  
> },  
> state: {  
> type: DataTypes.ENUM(‘disconnected’,‘available’,‘busy’, ‘error’, ‘passive’),  
> defaultValue: “disconnected”,  
> allowNull: false,  
> },  
> name: {  
> type: DataTypes.STRING,  
> },  
> operatorName: {  
> type: DataTypes.STRING,  
> field: ‘operator\_name’,  
> },  
> identifier: {  
> type: DataTypes.STRING,  
> allowNull: false,  
> },  
> roaming: {  
> type: DataTypes.BOOLEAN,  
> allowNull: false,  
> defaultValue: false,  
> field: ‘roaming’,  
> },  
> address1: {  
> type: DataTypes.STRING,  
> },  
> address2: {  
> type: DataTypes.STRING,  
> },  
> address3: {  
> type: DataTypes.STRING,  
> },  
> city: {  
> type: DataTypes.STRING,  
> },  
> zip: {  
> type: DataTypes.STRING,  
> },  
> parkingSpot: {  
> type: DataTypes.STRING,  
> field: ‘parking\_spot’,  
> },  
> note: {  
> type: DataTypes.STRING,  
> },  
> visibility: {  
> type: DataTypes.ENUM(‘public’,‘private’),  
> allowNull: false,  
> },  
> type: {  
> type: DataTypes.ENUM(‘ac’,‘dc’),  
> },  
> maxKw: {  
> type: DataTypes.DOUBLE,  
> field: ‘max\_kw’,  
> },  
> kwhCostType: {  
> type: DataTypes.ENUM(‘fixed’,‘spot’),  
> field: ‘kwh\_cost\_type’,  
> defaultValue: “fixed”,  
> allowNull: false,  
> },  
> kwhCostFixedPrice: {  
> type: DataTypes.DOUBLE,  
> field: ‘kwh\_cost\_fixed\_price’,  
> },  
> kwhCostSpotOverheadPercentage: {  
> type: DataTypes.DOUBLE,  
> field: ‘kwh\_cost\_spot\_overhead\_percentage’,  
> },  
> kwhCostSpotOverheadValue: {  
> type: DataTypes.DOUBLE,  
> field: ‘kwh\_cost\_spot\_overhead\_value’,  
> },  
> kwhSalesType: {  
> type: DataTypes.ENUM(‘fixed’,‘spot’),  
> field: ‘kwh\_sales\_type’,  
> defaultValue: “fixed”,  
> allowNull: false,  
> },  
> kwhSalesFixedPrice: {  
> type: DataTypes.DOUBLE,  
> field: ‘kwh\_sales\_fixed\_price’,  
> },  
> kwhSalesSpotOverheadPercentage: {  
> type: DataTypes.DOUBLE,  
> field: ‘kwh\_sales\_spot\_overhead\_percentage’,  
> },  
> kwhSalesSpotOverheadValue: {  
> type: DataTypes.DOUBLE,  
> field: ‘kwh\_sales\_spot\_overhead\_value’,  
> },  
> hasCable: {  
> type: DataTypes.INTEGER,  
> field: ‘has\_cable’,  
> },  
> hasAuthTokens: {  
> type: DataTypes.INTEGER,  
> field: ‘has\_auth\_tokens’,  
> defaultValue: 0,  
> allowNull: false,  
> },  
> chargePointModelCustom: {  
> type: DataTypes.STRING,  
> field: ‘charge\_point\_model\_custom’,  
> },  
> smartChargeSetting: {  
> type: DataTypes.ENUM(‘off’,‘optional’,‘forced’,‘forced-setting’),  
> field: ‘smart\_charge\_setting’,  
> allowNull: false,  
> },  
> smartChargePriorityPrice: {  
> type: DataTypes.INTEGER,  
> field: ‘smart\_charge\_priority\_price’,  
> defaultValue: 0,  
> allowNull: false,  
> },  
> smartChargePriorityCo2: {  
> type: DataTypes.INTEGER,  
> field: ‘smart\_charge\_priority\_co2’,  
> defaultValue: 0,  
> allowNull: false,  
> },  
> smartChargePriorityRenewable: {  
> type: DataTypes.INTEGER,  
> field: ‘smart\_charge\_priority\_renewable’,  
> defaultValue: 0,  
> allowNull: false,  
> },  
> activeAt: {  
> type: DataTypes.DATE,  
> field: ‘active\_at’,  
> },  
> chatActiveAt: {  
> type: DataTypes.DATE,  
> field: ‘chat\_active\_at’,  
> },  
> autoMovedToGroup: {  
> type: DataTypes.INTEGER,  
> field: ‘auto\_moved\_to\_group’,  
> defaultValue: 0,  
> allowNull: false,  
> },  
> autoStart: {  
> type: DataTypes.ENUM(‘off’,‘instant-start’,‘instant-schedule’,‘request-start’,‘request-schedule’),  
> field: ‘auto\_start’,  
> defaultValue: “off”,  
> allowNull: false,  
> },  
> lastActiveAt: {  
> type: DataTypes.DATE,  
> field: ‘last\_active\_at’,  
> },  
> integrationActiveAt: {  
> type: DataTypes.DATE,  
> field: ‘integration\_active\_at’,  
> },  
> chargingStartedAt: {  
> type: DataTypes.DATE,  
> field: ‘charging\_started\_at’,  
> },  
> integrationCount: {  
> type: DataTypes.INTEGER,  
> field: ‘integration\_count’,  
> defaultValue: 0,  
> allowNull: false,  
> },  
> staticMapPath: {  
> type: DataTypes.STRING,  
> field: ‘static\_map\_path’,  
> },  
> staticMapPathUpdatedAt: {  
> type: DataTypes.DATE,  
> field: ‘static\_map\_path\_updated\_at’,  
> },  
> nextScheduleAt: {  
> type: DataTypes.DATE,  
> field: ‘next\_schedule\_at’,  
> },  
> timezone: {  
> type: DataTypes.STRING,  
> },  
> operatorCutPercentage: {  
> type: DataTypes.DOUBLE,  
> field: ‘operator\_cut\_percentage’,  
> defaultValue: Sequelize.literal(‘0.0000’),  
> allowNull: false,  
> },  
> operatorCutAbsolute: {  
> type: DataTypes.DOUBLE,  
> field: ‘operator\_cut\_absolute’,  
> allowNull: false,  
> },  
> log: {  
> type: DataTypes.JSON,  
> allowNull: false,  
> },  
> createdAt: {  
> type: DataTypes.DATE,  
> field: ‘created\_at’,  
> },  
> updatedAt: {  
> type: DataTypes.DATE,  
> field: ‘updated\_at’,  
> },  
> deletedAt: {  
> type: DataTypes.DATE,  
> field: ‘deleted\_at’,  
> },  
> location: {  
> type: DataTypes.BLOB,  
> field: ‘location’,  
> },  
> maxReservationMin: {  
> type: DataTypes.INTEGER,  
> field: ‘max\_reservation\_min’,  
> allowNull: true,  
> defaultValue: null,  
> },  
> }, {  
> tableName: ‘charge\_points’,  
> });  
> // This section contains the relationships for this model. See: [https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships](https://docs.forestadmin.com/documentation/v/v6/reference-guide/relationships#adding-relationships).  
> ChargePoints.associate = (models) =\> {  
> ChargePoints.belongsTo(models.chargePointGroups, {  
> foreignKey: {  
> name: ‘chargePointGroupIdKey’,  
> field: ‘charge\_point\_group\_id’,  
> },  
> as: ‘chargePointGroup’,  
> });  
> ChargePoints.belongsTo(models.serverChargePointModels, {  
> foreignKey: {  
> name: ‘chargePointModelIdKey’,  
> field: ‘charge\_point\_model\_id’,  
> },  
> as: ‘chargePointModel’,  
> });  
> ChargePoints.belongsTo(models.countryAreas, {  
> foreignKey: {  
> name: ‘countryAreaIdKey’,  
> field: ‘country\_area\_id’,  
> },  
> as: ‘countryArea’,  
> });  
> ChargePoints.belongsTo(models.countries, {  
> foreignKey: {  
> name: ‘countryIdKey’,  
> field: ‘country\_id’,  
> },  
> as: ‘country’,  
> });  
> ChargePoints.belongsTo(models.currencies, {  
> foreignKey: {  
> name: ‘currencyIdKey’,  
> field: ‘currency\_id’,  
> },  
> as: ‘currency’,  
> });  
> ChargePoints.belongsTo(models.operators, {  
> foreignKey: {  
> name: ‘operatorIdKey’,  
> field: ‘operator\_id’,  
> },  
> as: ‘operator’,  
> });  
> ChargePoints.belongsTo(models.teams, {  
> foreignKey: {  
> name: ‘teamIdKey’,  
> field: ‘team\_id’,  
> },  
> as: ‘team’,  
> });  
> ChargePoints.belongsTo(models.users, {  
> foreignKey: {  
> name: ‘userIdKey’,  
> field: ‘user\_id’,  
> },  
> as: ‘user’,  
> });  
> ChargePoints.belongsToMany(models.connectors, {  
> through: ‘chargePointConnector’,  
> foreignKey: ‘charge\_point\_id’,  
> otherKey: ‘connector\_id’,  
> as: ‘connectorsThroughChargePointConnectors’,  
> });  
> ChargePoints.belongsToMany(models.users, {  
> through: ‘sponsoredChargePointUser’,  
> foreignKey: ‘sponsored\_charge\_point\_id’,  
> otherKey: ‘user\_id’,  
> as: ‘usersThroughSponsoredChargePointUsers’,  
> });  
> ChargePoints.hasMany(models.chargePointAssets, {  
> foreignKey: {  
> name: ‘chargePointIdKey’,  
> field: ‘charge\_point\_id’,  
> },  
> as: ‘chargePointChargePointAssets’,  
> });  
> ChargePoints.hasMany(models.chargePointIntegration, {  
> foreignKey: {  
> name: ‘chargePointIdKey’,  
> field: ‘charge\_point\_id’,  
> },  
> as: ‘chargePointChargePointIntegrations’,  
> });  
> ChargePoints.hasMany(models.chargePointReadings, {  
> foreignKey: {  
> name: ‘chargePointIdKey’,  
> field: ‘charge\_point\_id’,  
> },  
> as: ‘chargePointChargePointReadings’,  
> });  
> ChargePoints.hasMany(models.chargePointSchedules, {  
> foreignKey: {  
> name: ‘chargePointIdKey’,  
> field: ‘charge\_point\_id’,  
> },  
> as: ‘chargePointChargePointSchedules’,  
> });  
> ChargePoints.hasMany(models.charges, {  
> foreignKey: {  
> name: ‘chargePointIdKey’,  
> field: ‘charge\_point\_id’,  
> },  
> as: ‘chargePointCharges’,  
> });  
> ChargePoints.hasMany(models.hubjectOperators, {  
> foreignKey: {  
> name: ‘chargePointIdKey’,  
> field: ‘charge\_point\_id’,  
> },  
> as: ‘chargePointHubjectOperators’,  
> });  
> ChargePoints.hasMany(models.notificationEventUser, {  
> foreignKey: {  
> name: ‘userIdKey’,  
> field: ‘user\_id’,  
> },  
> as: ‘userNotificationEventUsers’,  
> });  
> ChargePoints.hasMany(models.notifications, {  
> foreignKey: {  
> name: ‘userIdKey’,  
> field: ‘user\_id’,  
> },  
> as: ‘userNotifications’,  
> });  
> ChargePoints.hasMany(models.sponsoredChargePoints, {  
> foreignKey: {  
> name: ‘chargePointIdKey’,  
> field: ‘charge\_point\_id’,  
> },  
> as: ‘chargePointSponsoredChargePoints’,  
> });  
> };  
> return ChargePoints;  
> };

---

<div class="post-metadata">

**Author:** ![anon34731316](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@anon34731316](https://community.forestadmin.com/u/anon34731316)\
**Post date:** [August 3, 2021, 9:46am UTC](https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033/5 "2021-08-03T09:46:45Z")

</div>

Hi @Arda_Yurdakul,

Thanks for your prompt response.

I am able to reproduce your issue.  
The problem seems to appear at version 7.8 of forest-express-sequelize.

We are going to work asap on a fix, and I let you know when it will be done.  
Meanwhile, if this is a big pain for you, I can only recommend to downgrade to 7.7.

Thanks again for this report 🙏

---

<div class="post-metadata">

**Author:** ![Arda\_Yurdakul](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arda_yurdakul/32/2334_2.png) [@Arda\_Yurdakul](https://community.forestadmin.com/u/Arda_Yurdakul)\
**Post date:** [August 3, 2021, 9:53am UTC](https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033/6 "2021-08-03T09:53:34Z")

</div>

Hi @anon34731316 ,

Thank you so much. I assumed you wanted to check if the column definitions had the ‘field’ variable set. That wasn’t the issue unfortunately. This is a real issue for us as we use scopes on many tables. I’m looking forward to the fix 👍

---

<div class="post-metadata">

**Author:** ![anon39940173](https://avatars.discourse-cdn.com/v4/letter/a/8c91f0/32.png) [@anon39940173](https://community.forestadmin.com/u/anon39940173)\
**Post date:** [August 9, 2021, 3:43pm UTC](https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033/7 "2021-08-09T15:43:43Z")

</div>

Hello @Arda_Yurdakul

We just released forest-express-sequelize@8.0.9 which includes the fix for this bug.  
Hopefully upgrading should resolve your issue.

(Come back to us if you are still having issues!)

---

<div class="post-metadata">

**Author:** ![Arda\_Yurdakul](https://dub1.discourse-cdn.com/flex013/user_avatar/community.forestadmin.com/arda_yurdakul/32/2334_2.png) [@Arda\_Yurdakul](https://community.forestadmin.com/u/Arda_Yurdakul)\
**Post date:** [August 10, 2021, 3:01pm UTC](https://community.forestadmin.com/t/cannot-filter-or-use-scope-on-related-data/3033/8 "2021-08-10T15:01:05Z")

</div>

Hello again @anon39940173

Yes the issue is resolved. Thank you so much 💯
