{"action":"opened","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/9116","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/9116/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/9116/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/9116/events","html_url":"https://github.com/sequelize/sequelize/issues/9116","id":300785859,"number":9116,"title":"Possibility of having an ARRAY datatype with CITEXT fields","user":{"login":"adriaanvanrossum","id":1079135,"avatar_url":"https://avatars3.githubusercontent.com/u/1079135?v=4","gravatar_id":"","url":"https://api.github.com/users/adriaanvanrossum","html_url":"https://github.com/adriaanvanrossum","followers_url":"https://api.github.com/users/adriaanvanrossum/followers","following_url":"https://api.github.com/users/adriaanvanrossum/following{/other_user}","gists_url":"https://api.github.com/users/adriaanvanrossum/gists{/gist_id}","starred_url":"https://api.github.com/users/adriaanvanrossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adriaanvanrossum/subscriptions","organizations_url":"https://api.github.com/users/adriaanvanrossum/orgs","repos_url":"https://api.github.com/users/adriaanvanrossum/repos","events_url":"https://api.github.com/users/adriaanvanrossum/events{/privacy}","received_events_url":"https://api.github.com/users/adriaanvanrossum/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-27T20:44:21Z","updated_at":"2018-02-27T20:44:21Z","closed_at":null,"author_association":"NONE","body":"## What are you doing?\r\n<!-- Post a minimal, self-contained code sample that reproduces the issue, including models and associations -->\r\n\r\nI am trying to add a custom datatype for CITEXT as part of an ARRAY. I search the database with case insensitive because I don't control the search terms. Is this possible to do with sequelize?\r\n\r\nI tried this:\r\n\r\n```js\r\nexport default (sequelize, DataTypes) => {\r\n  class CITEXT extends DataTypes.TEXT {\r\n    constructor () {\r\n      super()\r\n      this.key = 'CITEXT'\r\n    }\r\n  }\r\n\r\n  const Model = sequelize.define('artist', {\r\n    id: {\r\n      allowNull: false,\r\n      autoIncrement: true,\r\n      primaryKey: true,\r\n      type: DataTypes.INTEGER\r\n    },\r\n    slug: {\r\n      allowNull: false,\r\n      type: 'CITEXT' // <-- here I use a custom class, this works\r\n    },\r\n    names: {\r\n      allowNull: false,\r\n      type: DataTypes.ARRAY(CITEXT) // <-- but this does not work\r\n    }\r\n  });\r\n\r\n  return Model;\r\n};\r\n```\r\n\r\n## What do you expect to happen?\r\nThat I could access the ARRAY in sequelize like a normal JS array.\r\n\r\n## What is actually happening?\r\nThis is what I got in the console (which looks correct)\r\n\r\n```sql\r\nCREATE TABLE IF NOT EXISTS \"artists\" (\"id\" SERIAL, \"slug\" CITEXT NOT NULL, \"names\" CITEXT[] NOT NULL, \"createdAt\" TIMESTAMP WITH TIME ZONE NOT NULL, \"updatedAt\" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY (\"id\"));\r\n```\r\n\r\nBut this is what I get in the JS code\r\n\r\n```js\r\nsequelize.sync({ force: true }).then(() => {\r\n  return models.artist.create(\r\n    slug: 'cali-dubuque',\r\n    names: ['Cali DuBuque']\r\n  }).then(artist => {\r\n    console.log('===> artist.names', artist.get('names'))\r\n    // ===> artist.names {\"Cali DuBuque\"}\r\n  });\r\n});\r\n```\r\n\r\n`artist.get('names')` should output an array `['Cali DuBuque']` instead of a string `'{\"Cali DuBuque\"}'`\r\n\r\n__Dialect:__ postgres\r\n__Dialect version:__ 7.4.1 (node package `pg`)\r\n__Database version:__ 10.2 (`psql --version`)\r\n__Sequelize version:__ 4.34.1\r\n__Tested with latest release:__ yes"}}
{"actor":{"display_login":"adriaanvanrossum"}}