Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Column name with a 0 generate an invalid column name in query #369

Open
DeadEye0112 opened this issue Dec 30, 2019 · 2 comments
Open

Column name with a 0 generate an invalid column name in query #369

DeadEye0112 opened this issue Dec 30, 2019 · 2 comments
Labels

Comments

@DeadEye0112
Copy link

DeadEye0112 commented Dec 30, 2019

Expected behavior

Expected to be able to click on my table in Forest Admin and see the contents of the table.

Actual behavior

Having the message "Oops, something went wrong".

Failure Logs

[forest] 🌳🌳🌳  Unexpected error: column ratings.criteria0_grade does not exist
SequelizeDatabaseError: column ratings.criteria0_grade does not exist

Context

I have a table named ratings having several columns named like this: criteria_0_grade, criteria_1_grade, etc... For an unknown reason, Lumber seems to map these columns to criteria0_grade triggering a column ratings.criteria0_grade does not exist error. The problem seems to exist only with the two columns name criteria_0_*.

In models/ratings.js, only the columns with a 0 does not have a field field:

    criteria0Grade: {
      type: DataTypes.INTEGER,
    },
    criteria0Comment: {
      type: DataTypes.STRING,
    },
    criteria1Grade: {
      type: DataTypes.INTEGER,
      field: 'criteria_1_grade',
    },
    criteria1Comment: {
      type: DataTypes.STRING,
      field: 'criteria_1_comment',
    },
    criteria2Grade: {
      type: DataTypes.INTEGER,
      field: 'criteria_2_grade',
    },
  • Lumber Package Version: 3.0.1
  • Database Dialect: postgres
  • Database Version: 10.6

Thanks for you help!

@DeadEye0112 DeadEye0112 changed the title Column name with a number generate an invalid column name in query Column name with a 0 generate an invalid column name in query Dec 30, 2019
@arnaudbesnier
Copy link
Member

Hi @DeadEye0112,
Thanks for your feedback.
It definitely looks like a bug.

As a workaround could you edit your criteria0Grade and criteria0Comment fields, like this:

criteria0Grade: {
  type: DataTypes.INTEGER,
  field: 'criteria_0_grade' // define the name of your table column
},
criteria0Comment: {
  type: DataTypes.STRING,
  field: 'criteria_0_comment' // define the name of your table column
},

Hope it will help.

@DeadEye0112
Copy link
Author

I confirm that the workaround works, I hope that the fix will not disappear on update.

Thanks for your answer!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants