I am getting a query error that seems to be related to naming. The models have been generated using the latest lumber. Any advice?
Hello @Santosh_Srinivas, thanks for your feedback, and welcome in the community
Can you try to activate logging on sequelize?
Modify your .env
file and set the variable NODE_ENV
to development
.
As you can see in models/index.js
, it activates the logging on sequelize.
let databaseOptions = {
logging: process.env.NODE_ENV === 'development' ? console.log : false,
pool: { maxConnections: 10, minConnections: 1 },
dialectOptions: {},
};
// [...]
let sequelize = new Sequelize(process.env.DATABASE_URL, databaseOptions);
You’ll be able to see which query throws an error.
Hello @Santosh_Srinivas
Thank you for sharing the logs, would you be able to share the definition of your plants
model
Here …
// 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
module.exports = (sequelize, DataTypes) => {
const { Sequelize } = sequelize;
// This section contains the fields of your model, mapped to your table's columns.
// Learn more here: https://docs.forestadmin.com/documentation/v/v6/reference-guide/models/enrich-your-models#declaring-a-new-field-in-a-model
const Plants = sequelize.define('plants', {
internalIngredientId: {
type: DataTypes.INTEGER,
field: 'internal_ingredient_ID',
},
ingredientName: {
type: DataTypes.STRING,
field: 'Ingredient name',
},
scientificName: {
type: DataTypes.STRING,
field: 'Scientific Name',
},
foodbIngredientName: {
type: DataTypes.STRING,
field: 'foodb_ingredient_name',
},
hasENumber: {
type: DataTypes.STRING,
field: 'has E number?',
},
foodGroup: {
type: DataTypes.STRING,
field: 'food_group',
},
foodSubgroup: {
type: DataTypes.STRING,
field: 'food_subgroup',
},
partOfThePlant: {
type: DataTypes.STRING,
field: 'Part of the plant',
},
species: {
type: DataTypes.DOUBLE,
field: 'Species',
},
genus: {
type: DataTypes.DOUBLE,
field: 'Genus',
},
family: {
type: DataTypes.STRING,
field: 'Family',
},
functionalities: {
type: DataTypes.STRING,
field: 'Functionalities',
},
subFunctionalities: {
type: DataTypes.STRING,
field: 'Sub-functionalities',
},
nutritionalHealthBenefit: {
type: DataTypes.STRING,
field: 'Nutritional / health benefit',
},
additionalInfo: {
type: DataTypes.STRING,
field: 'Additional info',
},
sourceReference: {
type: DataTypes.STRING,
field: 'Source / Reference',
},
Thank you @Santosh_Srinivas
I think some part of the model definition is shrunk, can you please share the second part of the model?
sorry @anon90145840 … I put it here https://pastebin.com/XmysjGf1
Thank you for sharing the information. After some tests, it seems that your field Calories (Kcal/100g)
is the issue. Sequilize doesn’t seem to handle well the /
character in the name.
I am not sure how you can solve this issue except renaming the column. Sorry
There is an issue here, for sure.
Let us investigate a bit on this and we’ll come back to you as soon as we have a solution/more info to share.
Thank you for your patience!
Hello @Santosh_Srinivas,
Could you try a simple thing. I think it could help.
Transform all your fields containing parenthesis this way:
'Calories (Kcal/100g)': {
type: DataTypes.DOUBLE,
},
In order to have the same field and fieldname.
Let me know if it helps
Thanks @Guillaume_Cisco. Too much work for my data structure. I’ll keep this in mind however and try out.
Hello @Santosh_Srinivas
You can find in this pastebin the updated version of your file following the recommendation.
Could you try it?
Let me know if it helps resolving your issue
Hi @Guillaume_Cisco,
Sorry for the delay. New error:
(node:63045) [SEQUELIZE0001] DeprecationWarning: Use sequelize.fn / sequelize.literal to construct attributes
(Use `node --trace-deprecation ...` to show where the warning was created)
Executing (default): SELECT "internal_ingredient_ID" AS "internalIngredientId", "Ingredient name" AS "ingredientName", "Scientific Name" AS "scientificName", "foodb_ingredient_name" AS "foodbIngredientName", "has E number?" AS "hasENumber", "food_group" AS "foodGroup", "food_subgroup" AS "foodSubgroup", "Part of the plant" AS "partOfThePlant", "Species" AS "species", "Genus" AS "genus", "Family" AS "family", "Functionalities" AS "functionalities", "Sub-functionalities" AS "subFunctionalities", "Nutritional / health benefit" AS "nutritionalHealthBenefit", "Additional info" AS "additionalInfo", "Source / Reference" AS "sourceReference", "Scientific Validation" AS "scientificValidation", "Image - link" AS "imageLink", "foodb_food_public_id" AS "foodbFoodPublicId", "foodb_public_id" AS "foodbPublicId", "Calories (Kcal/100g)", "Proteins (%)", "Net / Total Available Carbohydrates (%)", "Free Sugars (%)", "Sodium (%)", "Total Fats (%)", "Saturated Fats (%)", "Mono-insaturated Fats (%)", "Poly-insaturated Fats (%)", "Trans Fats (%)", "Cholesterol (%)", Total Fiber (%) AS "totalFiber", "Soluble Fiber (%)", "Insoluble Fiber (%)", "Vitamins" AS "vitamins", "Minerals" AS "minerals", "Toxicity (Y/N, based on NOEL Value)", "Health Related Concern" AS "healthRelatedConcern", "Explanation of why it has that effect" AS "explanationOfWhyItHasThatEffect", "Rasa" AS "rasa", "Guna" AS "guna", "Dosha" AS "dosha", "Panchabuta" AS "panchabuta", "Temperature" AS "temperature", "Melting/Freezing Point (°C)", "Boiling Point (°C)", "pKa", "pH @ maximum available concentration, RT" AS "pHMaximumAvailableConcentrationRt", "EC" AS "ec", "Moisture (%)", "Coefficent of expansion - Moisture" AS "coefficentOfExpansionMoisture", "Porosity (%)", "Density (g/L)", "Flammability" AS "flammability", "Thermal Stability" A
Thank you @Santosh_Srinivas, It looks like there is an error with this column name.
I missed to translate it in the pastebin I sent you.
Could you transform it to:
'Total Fiber (%)',: {
type: DataTypes.DOUBLE,
},
And test again ?
Let me know
No idea what happened but I can’t access the plants
model anymore!?
'Total Fiber (%)': {
type: DataTypes.DOUBLE,
},
There was an extra comma in my previous message after 'Total Fiber (%)'
. Sorry for that.
Is that ok now?
I corrected that but the model has disappeared from the UI
Hello @Santosh_Srinivas
Thank you for your patience.
Could you please try to go to the Layout Editor and check that the collection is not hidden? Here is an article about how to do it.
By default in the app when the new collection is added it is hidden for security reasons.
Thx @anon90145840 … another error now
Hey @anon90145840, @Guillaume_Cisco … can we do a zoom call to figure this out quickly?