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
include Sequelize.col s.replace is not a function #12361
Comments
Can you include the stack trace? Also what is the value of |
this.ctx.params.handle is a filtered index that does not affect the query
|
|
But I searched the information in the community. Someone wrote this in the v4 version, and it worked. The difference is that his database is mysql, mine is postgresql. |
I tried this on both |
SSCCE Only fails when used in (async () => {
const User = sequelize.define("user", {
name: DataTypes.STRING,
});
const Project = sequelize.define("project", {
name: DataTypes.STRING,
});
User.hasMany(Project);
Project.belongsTo(User);
await sequelize.sync({ force: true });
const result = await User.findOne({
include: [
{
model: Project,
attributes: ["id", Sequelize.col("project.name")],
},
],
where: {
name: "abc",
},
});
console.log(result);
})().catch((e) => console.error(e)); Executing (default): DROP TABLE IF EXISTS `projects`;
Executing (default): DROP TABLE IF EXISTS `users`;
Executing (default): DROP TABLE IF EXISTS `users`;
Executing (default): CREATE TABLE IF NOT EXISTS `users` (`id` INTEGER NOT NULL auto_increment , `name` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `users`
Executing (default): DROP TABLE IF EXISTS `projects`;
Executing (default): CREATE TABLE IF NOT EXISTS `projects` (`id` INTEGER NOT NULL auto_increment , `name` VARCHAR(255), `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, `userId` INTEGER, PRIMARY KEY (`id`), FOREIGN KEY (`userId`) REFERENCES `users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE) ENGINE=InnoDB;
Executing (default): SHOW INDEX FROM `projects`
TypeError: s.replace is not a function
at Object.removeTicks (/var/projects/oss/sequelize/lib/utils.js:347:12)
at Object.quoteIdentifier (/var/projects/oss/sequelize/lib/dialects/abstract/query-generator/helpers/quote.js:47:35)
at MySQLQueryGenerator.quoteIdentifier (/var/projects/oss/sequelize/lib/dialects/abstract/query-generator.js:891:24)
at /var/projects/oss/sequelize/lib/dialects/abstract/query-generator.js:1519:74
at Array.map (<anonymous>)
at MySQLQueryGenerator.generateInclude (/var/projects/oss/sequelize/lib/dialects/abstract/query-generator.js:1483:52)
at MySQLQueryGenerator.selectQuery (/var/projects/oss/sequelize/lib/dialects/abstract/query-generator.js:1183:34)
at MySQLQueryInterface.select (/var/projects/oss/sequelize/lib/dialects/abstract/query-interface.js:939:27)
at Function.findAll (/var/projects/oss/sequelize/lib/model.js:1741:47)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
|
This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
Getting this error while doing bulk insert
|
Likewise. |
Getting same issue, any update on this thread? |
I'm running into this error when I use a calculated index field in conjunction with Report.init(
{
id: {
type: DataTypes.INTEGER,
autoIncrement: true,
primaryKey: true
},
userId: {
type: DataTypes.INTEGER,
allowNull: true,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},
createdAt: DataTypes.DATE,
updatedAt: DataTypes.DATE,
},
{
sequelize,
tableName: 'reports',
indexes: [
{
name: 'idx_managed_report',
fields: [sequelize.literal('("userId" is null)'), 'name'], // this line here
unique: true,
where: { userId: null },
},
},
},
);
await Report.upsert({ name: 'All Data' }); |
Issue Description
What are you doing?
I get an exception when querying data through the association table and combining fields.
For example, collections is the main table, collection_products is the associated table, and products is the associated word table.
The query statement is as follows:
What do you expect to happen?
输出结果
What is actually happening?
An error message was output
Additional context
Environment
Issue Template 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: