Feature(s) impacted
Search on CapitalDepositCaseModel collection
Observed behavior
On the Forest Admin Frontend, in a collection, when searching for something
We get an error
Expected behavior
The application should successfully return the result of the searching query.
Failure Logs
[forest] 🌳🌳🌳 Unexpected error: function lower(uuid) does not exist
{
"name": "SequelizeDatabaseError",
"parent": {
"length": 204,
"name": "error",
"severity": "ERROR",
"code": "42883",
"hint": "No function matches the given name and argument types. You might need to add explicit type casts.",
"position": "91",
"file": "parse_func.c",
"line": "627",
"routine": "ParseFuncOrColumn",
"sql": "[ContainsSensitiveData]"
},
"stack": "SequelizeDatabaseError: function lower(uuid) does not exist"
}
Context
- Project name: Swan Social Capital Deposit
- Team name: Swan
- Environment name: Master
- Agent type & version: 8.2.8
The issue seems similar to this one : Search on collection is sending an error - "function lower(uuid) does not exist"
It seems related to the fact that although they are UUID, our id fields are treated as Strings.
Let’s focus on the CapitalDepositCaseModel, which takes an id, as a UUID v4.
In our model, we defined the id of our capitalDepositCase as a UUID using sequelize-typescript
:
// capital-deposit-case.model.ts
@Table({ tableName: CapitalDepositCaseModel.tableName, timestamps: false })
export class CapitalDepositCaseModel extends Model<
CapitalDepositCaseModel,
Partial<CapitalDepositCaseModel>
> {
public static tableName = "CapitalDepositCase";
@IsUUID(4)
@Default(DataType.UUIDV4)
@PrimaryKey
@Column
id!: string;
...
}
In our database, it is saved as UUID
We do not have specified the type of the id field on the config file
// capital-deposit-case.config.forest.ts
forest.collection("CapitalDepositCaseModel", {
fields: [
{
field: "CapitalDepositCaseDocument",
type: ["String"],
reference: "CapitalDepositCaseDocumentModel.id",
},
],
...
})
The final configuration seems to infer the id column as a string instead of a UUID.
// .forestadmin-schema.json
{
"name": "CapitalDepositCaseModel",
"nameOld": "CapitalDepositCaseModel",
"icon": null,
"integration": null,
"isReadOnly": false,
"isSearchable": true,
"isVirtual": false,
"onlyForRelationships": false,
"paginationType": "page",
"fields": [{
"field": "id",
"type": "String",
"defaultValue": null,
"enums": null,
"integration": null,
"isFilterable": true,
"isPrimaryKey": true,
"isReadOnly": false,
"isRequired": true,
"isSortable": true,
"isVirtual": false,
"reference": null,
"inverseOf": null,
"validations": []
}...
}
At the end, when performing the query, we get the Unexpected error: function lower(uuid) does not exist
error.
One possibility may be to override all our uuid fields by filling their values in the *config.forest.ts
files, but this would take a bit of work, and I am not reassured that this would break because of our relationships (although searching in relationship seems to imply using the extended search that we actually do not need, it is okay if we only search on the selected collection fields).
Thank you for your support,
Nicolas