{"action":"created","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/5566","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/5566/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/5566/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/5566/events","html_url":"https://github.com/sequelize/sequelize/issues/5566","id":139872750,"number":5566,"title":"virtual attributes are always return by model","user":{"login":"p2227","id":4214942,"avatar_url":"https://avatars3.githubusercontent.com/u/4214942?v=3","gravatar_id":"","url":"https://api.github.com/users/p2227","html_url":"https://github.com/p2227","followers_url":"https://api.github.com/users/p2227/followers","following_url":"https://api.github.com/users/p2227/following{/other_user}","gists_url":"https://api.github.com/users/p2227/gists{/gist_id}","starred_url":"https://api.github.com/users/p2227/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/p2227/subscriptions","organizations_url":"https://api.github.com/users/p2227/orgs","repos_url":"https://api.github.com/users/p2227/repos","events_url":"https://api.github.com/users/p2227/events{/privacy}","received_events_url":"https://api.github.com/users/p2227/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-03-10T12:29:58Z","updated_at":"2017-05-25T17:31:44Z","closed_at":null,"body":"```\nvar pinyin = require('pinyin');\n\nmodule.exports = function(sequelize, DataTypes) {\n  var moneyType = sequelize.options.dialect === 'mssql' ? 'MONEY' : DataTypes.INTEGER;\n  return sequelize.define('Pt', {\n    usertype:{\n      type:DataTypes.VIRTUAL,\n      get(){\n        return '0'\n      }\n    },\n    pinyin:{\n      type:DataTypes.VIRTUAL,\n      scopes:['user'],\n      get(){\n        return pinyin(this.getDataValue('TX_Name'),{\n          segment:false,\n          style:pinyin.STYLE_NORMAL\n        }).join('')\n      }\n    },\n    ID_User: {\n      primaryKey: true,\n      type: DataTypes.STRING,\n      allowNull: false\n    },\n    TX_Name: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    DT_Birth: {\n      type: DataTypes.DATE,\n      get:function(){\n        var d = this.getDataValue('DT_Birth')\n        return d ? d.toLocaleString() : d; \n      },\n      allowNull: true\n    },\n    TX_IC: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_IMG: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_Location: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_Signature: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_Username: {\n      type: DataTypes.STRING,\n      allowNull: false\n    },\n    TX_Password: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_Contact: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_QQ: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_WeChat: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_QR: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    DT_Delivery: {\n      type: DataTypes.DATE,\n      get:function(){\n        var d = this.getDataValue('DT_Delivery')\n        return d ? d.toLocaleString() : d; \n      },\n      allowNull: true\n    },\n    TX_Name2: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    TX_Contact2: {\n      type: DataTypes.STRING,\n      allowNull: true\n    },\n    MN_Credit: {\n      type: moneyType,\n      allowNull: true\n    },\n    MN_Deposit: {\n      type: moneyType,\n      allowNull: true\n    },\n  }, {\n    defaultScope: {\n      attributes: { exclude: ['TX_Password'] }\n    },\n    scopes:{\n      'user':{\n        attributes:['ID_User','TX_Name','DT_Birth','TX_IC','TX_IMG','TX_Location','TX_Signature','TX_Username','TX_Password','TX_QR','TX_Contact','TX_QQ','TX_WeChat']\n      }\n    },\n    updatedAt:'DTTM_Updated',\n    createdAt:'DTTM_Created',\n    tableName: 'T_Pt',\n    freezeTableName: true\n  });\n};\n```\n\nthe attributes usertype and pinyin are always return where i findOne/findAll event i use model.scope('xxx')\n"},"comment":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/comments/304071694","html_url":"https://github.com/sequelize/sequelize/issues/5566#issuecomment-304071694","issue_url":"https://api.github.com/repos/sequelize/sequelize/issues/5566","id":304071694,"user":{"login":"huynhj93","id":20627284,"avatar_url":"https://avatars0.githubusercontent.com/u/20627284?v=3","gravatar_id":"","url":"https://api.github.com/users/huynhj93","html_url":"https://github.com/huynhj93","followers_url":"https://api.github.com/users/huynhj93/followers","following_url":"https://api.github.com/users/huynhj93/following{/other_user}","gists_url":"https://api.github.com/users/huynhj93/gists{/gist_id}","starred_url":"https://api.github.com/users/huynhj93/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huynhj93/subscriptions","organizations_url":"https://api.github.com/users/huynhj93/orgs","repos_url":"https://api.github.com/users/huynhj93/repos","events_url":"https://api.github.com/users/huynhj93/events{/privacy}","received_events_url":"https://api.github.com/users/huynhj93/received_events","type":"User","site_admin":false},"created_at":"2017-05-25T17:31:44Z","updated_at":"2017-05-25T17:31:44Z","body":"@wkkwok Is that fix now deprecated? I tried implementing it, but options.attributes seems to exclude the virtual attributes now. Thus, your model._customGetters will be an empty object now."}}
{"actor":{"display_login":"huynhj93"}}