Feature(s) impacted
Smart fields (first_name, last_name) and their search/filter functionality.
Observed behavior
I have defined two smart fields, first_name
and last_name
, which retrieve data from another table using a complex query. When I use collection.emulateFieldFiltering('first_name')
, it works but is very slow. When I attempt to manually override IContains
using collection.replaceFieldOperator
, I get an error stating:
Operator replacement cycle: profilesUser.first_name[IContains] -> profilesUser.first_name[IContains]
Expected behavior
I expect the first_name
and last_name
smart fields to be searchable and filterable without significant performance issues or errors.
Failure Logs
Here is the relevant code snippet:
const {fetchSubmissionItemValue} = require("../../utilities/reusable/fetchSubmissionItemValue");
module.exports = (agent) => {
agent.customizeCollection('profilesUser', collection => {
collection.addField('first_name', {
columnType: 'String',
dependencies: ['id'],
getValues: async (records, context) => {
return records.map(async record => {
return await fetchSubmissionItemValue(context, 9, record.id)
});
}
});
collection.addField('last_name', {
columnType: 'String',
dependencies: ['id'],
getValues: async (records, context) => {
return records.map(async record => {
return await fetchSubmissionItemValue(context, 10, record.id)
});
}
});
collection.addField('full_name', {
columnType: 'String',
dependencies: ['id', 'first_name', 'last_name'],
getValues: async (records, context) => {
return records.map(async record => {
return `${record.first_name} ${record.last_name}`
});
}
});
collection.replaceFieldOperator('first_name', 'IContains', (value, context) => {
return {
field: 'first_name',
operator: 'IContains',
value: value
}
});
});
}
Context
- Project name: Ourboro
- Team name: Customer Experience
- Environment name: Local
- Agent technology: nodejs
- Agent (forest package) name & version:
@forestadmin/agent
: “^1.39.2”@forestadmin/datasource-sql
: “^1.14.0”@forestadmin/datasource-toolkit
: “^1.33.0”
- Database type: Postgres
- Recent changes made on your end if any: -