{"action":"closed","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/5917","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/5917/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/5917/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/5917/events","html_url":"https://github.com/sequelize/sequelize/issues/5917","id":155569952,"number":5917,"title":"Use a Postgres function name as default value","user":{"login":"gustavohenrique","id":51675,"avatar_url":"https://avatars.githubusercontent.com/u/51675?v=3","gravatar_id":"","url":"https://api.github.com/users/gustavohenrique","html_url":"https://github.com/gustavohenrique","followers_url":"https://api.github.com/users/gustavohenrique/followers","following_url":"https://api.github.com/users/gustavohenrique/following{/other_user}","gists_url":"https://api.github.com/users/gustavohenrique/gists{/gist_id}","starred_url":"https://api.github.com/users/gustavohenrique/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gustavohenrique/subscriptions","organizations_url":"https://api.github.com/users/gustavohenrique/orgs","repos_url":"https://api.github.com/users/gustavohenrique/repos","events_url":"https://api.github.com/users/gustavohenrique/events{/privacy}","received_events_url":"https://api.github.com/users/gustavohenrique/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-05-18T18:27:15Z","updated_at":"2016-05-18T18:37:54Z","closed_at":"2016-05-18T18:37:54Z","body":"## What you are doing?\r\nI have a function in Postgres to generate IDs:\r\n\r\n```sql\r\ncreate schema if not exists shard_1;\r\ncreate sequence if not exists shard_1.global_id_sequence;\r\nCREATE OR REPLACE FUNCTION shard_1.id_generator(OUT result bigint) AS $$\r\nDECLARE\r\n    our_epoch bigint := 1314220021721;\r\n    seq_id bigint;\r\n    now_millis bigint;\r\n    shard_id int := 1;\r\nBEGIN\r\n    SELECT nextval('shard_1.global_id_sequence') % 1024 INTO seq_id;\r\n    SELECT FLOOR(EXTRACT(EPOCH FROM clock_timestamp()) * 1000) INTO now_millis;\r\n    result := (now_millis - our_epoch) << 23;\r\n    result := result | (shard_id << 10);\r\n    result := result | (seq_id);\r\nEND;\r\n$$ LANGUAGE PLPGSQL;\r\n```\r\n\r\nI would like to use my function name as default value in create table statement.\r\n```js\r\nvar User = sequelize.define('user', {\r\n    id: {\r\n        type: Sequelize.BIGINT,\r\n        primaryKey: true,\r\n        unique: true,\r\n        defaultValue: 'id_generator()'\r\n    },\r\n    name: {\r\n        type: Sequelize.STRING\r\n    }\r\n});\r\n```\r\n\r\n## What do you expect to happen?\r\nI wanted to generate the *CREATE TABLE* as:\r\n\r\n```sql\r\nCREATE TABLE IF NOT EXISTS \"users\" (\"id\" BIGINT DEFAULT id_generator() UNIQUE , \"name\" VARCHAR(255), PRIMARY KEY (\"id\"))\r\n```\r\n\r\n## What is actually happening?\r\nBut Sequelize is trying to use the attribute `id_generator()` as string.\r\n\r\n```sql\r\nCREATE TABLE IF NOT EXISTS \"users\" (\"id\" BIGINT DEFAULT 'id_generator()' UNIQUE , \"name\" VARCHAR(255), PRIMARY KEY (\"id\"))\r\n```\r\n\r\nOutput:\r\n```\r\nUnhandled rejection SequelizeDatabaseError: invalid input syntax for integer: \"id_generator()\"\r\n```\r\n\r\n\r\nDialect: postgres\r\nDatabase version: 9.5\r\nSequelize version: 3.23.2"}}