-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: bug column name when sequelize model mapping attribute has field… #283
fix: bug column name when sequelize model mapping attribute has field… #283
Conversation
… option access the schema field columnName instead access directly through the fieldName. Closed ForestAdmin#282 Closed ForestAdmin#273
return `${schema.name}.${fieldName}`; | ||
const schemaField = schema.fields.find(schemaField => schemaField.field === fieldName); | ||
const columnName = schemaField ? schemaField.columnName : fieldName; | ||
return `${schema.name}.${columnName}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could factorise this logic in a dedicated method.
It would improve the code maintenance and readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe there is already a method for this purpose in the existing code.
@@ -318,6 +319,24 @@ const HasManyDissociator = require('../src/services/has-many-dissociator'); | |||
}); | |||
|
|||
describe('A simple Line Chart per day on an empty users table', () => { | |||
it('should generate a valid SQL query when models mapped to another field', (done) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"when models mapped to another field" should actually be in a describe
in my opinion:
describe('A simple Line Chart per day on an empty users table', () => {
describe('with a group_by_date_field field having a conventional name', () => {
it('should generate a valid SQL query', (done) => {
// TEST
});
});
describe('with a group_by_date_field field having an unconventional name', () => {
it('should generate a valid SQL query', (done) => {
// TEST
});
});
});
Plus, not sure this PR fixes this issue: |
Co-Authored-By: Arnaud Besnier <[email protected]>
This PR inspired me for the fix. I close it in favor of this one: #301 |
Fixing bug column name when sequelize model mapping attribute has field option
access the schema field columnName instead access directly through the fieldName.
Closed #282
Closed #273
Pull Request checklist: