{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/3946","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/3946/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/3946/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/3946/events","html_url":"https://github.com/sequelize/sequelize/issues/3946","id":88803140,"number":3946,"title":"Back tick in PostgreSQL many-to-many query","user":{"login":"dtjohnson","id":218771,"avatar_url":"https://avatars.githubusercontent.com/u/218771?v=3","gravatar_id":"","url":"https://api.github.com/users/dtjohnson","html_url":"https://github.com/dtjohnson","followers_url":"https://api.github.com/users/dtjohnson/followers","following_url":"https://api.github.com/users/dtjohnson/following{/other_user}","gists_url":"https://api.github.com/users/dtjohnson/gists{/gist_id}","starred_url":"https://api.github.com/users/dtjohnson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtjohnson/subscriptions","organizations_url":"https://api.github.com/users/dtjohnson/orgs","repos_url":"https://api.github.com/users/dtjohnson/repos","events_url":"https://api.github.com/users/dtjohnson/events{/privacy}","received_events_url":"https://api.github.com/users/dtjohnson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-16T18:27:11Z","updated_at":"2015-06-16T19:28:28Z","closed_at":null,"body":"I have two models: Todo and Tags joined with a many-to-many relationship. Here is the Tag model:\r\n```javascript\r\nsequelize.define(\"Tag\", {\r\n    name: { type: DataTypes.STRING, allowNull: false, validate: { notEmpty: true } }\r\n}, {\r\n    tableName: \"tags\"\r\n});\r\n```\r\n\r\nAnd here is the Todo model:\r\n```javascript\r\nsequelize.define(\"Todo\", {\r\n    task: { type: DataTypes.STRING, allowNull: false, validate: { notEmpty: true } }\r\n}, {\r\n    tableName: \"todos\",\r\n    classMethods: {\r\n        associate: function (models) {\r\n            models.Todo.belongsToMany(models.Tag, { through: \"todoTags\", foreignKey: \"todoId\", as: \"tags\" });\r\n            models.Tag.belongsToMany(models.Todo, { through: \"todoTags\", foreignKey: \"tagId\", as: \"todos\" });\r\n        }\r\n    }\r\n});\r\n```\r\n\r\nI'm trying to add a tag with the following:\r\n```javascript\r\nmodels.Todo.findById(1)\r\n    .then(function (todo) {\r\n        return todo.addTag({ id: 1 });\r\n    });\r\n```\r\n\r\nThe generated SQL is:\r\n```sql\r\nSELECT \"id\", \"task\", \"data\", \"createdAt\", \"updatedAt\" FROM \"todos\" AS \"Todo\" WHERE \"Todo\".\"id\" = '1' LIMIT 1;\r\nSELECT \"Tag\".\"id\", \"Tag\".\"name\", \"Tag\".\"createdAt\", \"Tag\".\"updatedAt\", \"todoTags\".\"createdAt\" AS \"todoTags.createdAt\", \"todoTags\".\"updatedAt\" AS \"todoTags.updatedAt\", \"todoTags\".\"tagId\" AS \"todoTags.tagId\", \"todoTags\".\"todoId\" AS \"todoTags.todoId\" FROM \"tags\" AS \"Tag\" INNER JOIN \"todoTags\" AS \"todoTags\" ON \"Tag\".\"id\" = \"todoTags\".\"tagId\" AND \"todoTags\".\"todoId\" = 1 WHERE (\"Tag\".\"id\" = `id` = 1);\r\n```\r\n\r\nThe second statement contains back ticks and errors with the following:\r\n```\r\nSequelizeDatabaseError: operator does not exist: ` integer\r\n```\r\n\r\nLooks like a bug? Am I doing this right?"},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/112538294","html_url":"https://github.com/sequelize/sequelize/issues/3946#issuecomment-112538294","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/3946","id":112538294,"user":{"login":"janmeier","id":1210224,"avatar_url":"https://avatars.githubusercontent.com/u/1210224?v=3","gravatar_id":"","url":"https://api.github.com/users/janmeier","html_url":"https://github.com/janmeier","followers_url":"https://api.github.com/users/janmeier/followers","following_url":"https://api.github.com/users/janmeier/following{/other_user}","gists_url":"https://api.github.com/users/janmeier/gists{/gist_id}","starred_url":"https://api.github.com/users/janmeier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/janmeier/subscriptions","organizations_url":"https://api.github.com/users/janmeier/orgs","repos_url":"https://api.github.com/users/janmeier/repos","events_url":"https://api.github.com/users/janmeier/events{/privacy}","received_events_url":"https://api.github.com/users/janmeier/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T19:28:28Z","updated_at":"2015-06-16T19:28:28Z","body":"You should pass either a built instance or the id to addTag "}}