{"action":"closed","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/5991","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/5991/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/5991/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/5991/events","html_url":"https://github.com/sequelize/sequelize/issues/5991","id":157396294,"number":5991,"title":"ID not included in attributes on a join table","user":{"login":"dphaener","id":5187971,"avatar_url":"https://avatars.githubusercontent.com/u/5187971?v=3","gravatar_id":"","url":"https://api.github.com/users/dphaener","html_url":"https://github.com/dphaener","followers_url":"https://api.github.com/users/dphaener/followers","following_url":"https://api.github.com/users/dphaener/following{/other_user}","gists_url":"https://api.github.com/users/dphaener/gists{/gist_id}","starred_url":"https://api.github.com/users/dphaener/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dphaener/subscriptions","organizations_url":"https://api.github.com/users/dphaener/orgs","repos_url":"https://api.github.com/users/dphaener/repos","events_url":"https://api.github.com/users/dphaener/events{/privacy}","received_events_url":"https://api.github.com/users/dphaener/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-29T17:26:26Z","updated_at":"2016-05-30T06:58:59Z","closed_at":"2016-05-30T06:58:59Z","body":"## What you are doing?\r\n\r\nI have a table that joins `users` and `inspections` that is called `userinspections`. When I query only the join table, the primary key `id` is not included in the attributes. The migration looks like this:\r\n\r\n```js\r\n'use strict';\r\nmodule.exports = {\r\n  up: function(queryInterface, Sequelize) {\r\n    return queryInterface.createTable('UserInspections', {\r\n      id: {\r\n        allowNull: false,\r\n        autoIncrement: true,\r\n        primaryKey: true,\r\n        type: Sequelize.INTEGER\r\n      },\r\n      user_id: {\r\n        type: Sequelize.INTEGER\r\n      },\r\n      inspection_id: {\r\n        type: Sequelize.INTEGER\r\n      },\r\n      created_at: {\r\n        allowNull: false,\r\n        type: Sequelize.DATE\r\n      },\r\n      updated_at: {\r\n        allowNull: false,\r\n        type: Sequelize.DATE\r\n      },\r\n      deleted_at: {\r\n        allowNull: true,\r\n        type: Sequelize.DATE\r\n      }\r\n    });\r\n  },\r\n  down: function(queryInterface, Sequelize) {\r\n    return queryInterface.dropTable('UserInspections');\r\n  }\r\n};\r\n```\r\n\r\nThe model definition looks like this:\r\n\r\n```js\r\nimport baseModel from 'lib/models/model';\r\n\r\nexport default function(sequelize, DataTypes) {\r\n  const name = 'UserInspection'\r\n\r\n  const columns = {\r\n    user_id: DataTypes.INTEGER,\r\n    inspection_id: DataTypes.INTEGER\r\n  };\r\n\r\n  const options = {\r\n    classMethods: {\r\n      associate: function(models) {\r\n        // associations can be defined here\r\n      }\r\n    }\r\n  };\r\n\r\n  const UserInspection = baseModel({ name, columns, options }, sequelize);\r\n  return UserInspection;\r\n};\r\n```\r\n\r\nI am wrapping every model in that `baseModel` just to add some standard class methods to every model. This doesn't cause an issue with any other model.\r\n\r\n## What do you expect to happen?\r\n\r\nI am simply expecting the `id` column to be returned.\r\n\r\n## What is actually happening?\r\n\r\nThe `id` column is omitted from the query results. I can fix this by adding `id` to the column names in the model definition, but then I have to specify an `id` when inserting, which is not desirable.\r\n\r\n\r\n__Dialect:__ postgres\r\n__Database version:__ 9.5\r\n__Sequelize version:__ 3.21.0\r\n"}}
{"actor":{"display_login":"janmeier"}}