-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Update not using camelCase field names to snake_case for instance.update() call #13897
Comments
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
Is there anything I can do here to help? I would be more than happy to help but have no idea where to start. Seems like another part of the sequelize codebase was working based on the fact that before the linked commit, the where attributes were mutated. |
If cloning causes an issue, it must mean some part of the code was relying on a side-effect which is very annoying :/ A good starting point would be to open a PR with a failing test. But the next step is figuring out which part of the code fails, which is going to take some time unfortunately. Your Model does not have a Primary Key, that's probably relevant to the issue |
In the application I'm getting the issue, there is a primary key added when the table is created by a migration: await queryInterface.createTable('MarketDatasets', {
disabled: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
market_id: {
type: DataTypes.INTEGER,
primaryKey: true,
references: { model: 'Markets', key: 'id' },
},
dataset_id: {
type: DataTypes.INTEGER,
primaryKey: true,
references: { model: 'Datasets', key: 'id' },
},
created_at: {
allowNull: false,
type: DataTypes.DATE,
defaultValue: DataTypes.literal('CURRENT_TIMESTAMP'),
},
updated_at: {
allowNull: false,
type: DataTypes.DATE,
defaultValue: DataTypes.literal('CURRENT_TIMESTAMP'),
},
}, {
charset: 'utf8mb4',
collate: 'utf8mb4_general_ci',
}); Just to add to the context, the model looks like this: module.exports = (sequelize, DataTypes) => {
class MarketDatasets extends sequelize.Sequelize.Model { }
MarketDatasets.init(
{
disabled: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
},
{
sequelize,
timestamps: false,
},
);
MarketDatasets.removeAttribute('id');
MarketDatasets.associate = ({
Markets,
Datasets,
}) => {
MarketDatasets.belongsTo(Markets, {
foreignKey: 'marketId',
onDelete: 'cascade',
onUpdate: 'cascade',
});
MarketDatasets.belongsTo(Datasets, {
foreignKey: 'datasetId',
onDelete: 'cascade',
onUpdate: 'cascade',
});
};
return MarketDatasets;
}; |
I can't see anything specific in the documentation, what would the best place for the test be? Happy to write one up. Would the Foo/Bar representation from the SSCCE be the better use in the test or something closer resembling what I am actually using? |
Currently your SSCCE fails with |
Thanks for getting back to me @ephys, taking a look now (to try fix) I can see error is only for v5, the issue exists in v6 (I hadn't tried v5 as the app was built for v6) Looking at the SSCCE logs for v6 tests (not TypeScript ones) I am getting the correct error. From the MySQL 5.8 (v6) results:
Appears to be the same across all dialects in v6 tests. Did you want an SSCCE that gets the right error in v5 and v6 or is just the v6 one okay? |
Oh that's my bad, I didn't realise the SSCCE was still testing v5 too. Definitely something fishy going on in v6 here |
Issue Creation Checklist
Bug Description
SSCCE
Here is the link to the SSCCE for this issue: sequelize/sequelize-sscce#213
What do you expect to happen?
I expected the query to work update the row
What is actually happening?
I get an error that datasetId is an unknown column, which is correct because the database is in snake_case
Additional context
Environment
Bug Report Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: