0
sequelize: 1.7.0
pg: 2.11.1
posgreSql: 9.3 (pg server on my pc)

I have app that is using following config:

db: 'mysql://user:pass@localhost/dbname'

And it works with sequelize and mysql dialect. When I change it to:

db: 'postgres://user:pass@localhost/dbname'

and dialect to postgres and try to sequelize.sync() I get following error:

{
   "message":"syntax error at or near \"(\"",
   "name":"error",
   "stack":"error: syntax error at or near \"(\"\n    at Connection.parseE (/Users/me/Desktop/node/myapp/node_modules/pg/lib/connection.js:561:11)\n    at Connection.parseMessage (/Users/me/Desktop/node/myapp/node_modules/pg/lib/connection.js:390:17)\n    at [object Object].<anonymous> (/Users/me/Desktop/node/myapp/node_modules/pg/lib/connection.js:92:20)\n    at EventEmitter.emit (events.js:95:17)\n    at Socket.<anonymous> (_stream_readable.js:746:14)\n    at EventEmitter.emit (events.js:92:17)\n    at emitReadable_ (_stream_readable.js:408:10)\n    at emitReadable (_stream_readable.js:404:5)\n---------------------------------------------\n    at module.exports.CustomEventEmitter.failure.CustomEventEmitter.fail.CustomEventEmitter.error (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/emitters/custom-event-emitter.js:93:10)\n    at exec (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/query-chainer.js:92:14)\n    at onError (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/query-chainer.js:72:11)\n    at EventEmitter.emit (events.js:95:17)\n    at module.exports.CustomEventEmitter.emit (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/emitters/custom-event-emitter.js:61:33)\n    at [object Object].<anonymous> (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/emitters/custom-event-emitter.js:131:17)\n---------------------------------------------\n    at module.exports.CustomEventEmitter.failure.CustomEventEmitter.fail.CustomEventEmitter.error (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/emitters/custom-event-emitter.js:93:10)\n    at exec (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/query-chainer.js:92:14)\n    at onError (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/query-chainer.js:72:11)\n    at EventEmitter.emit (events.js:95:17)\n    at module.exports.CustomEventEmitter.emit (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/emitters/custom-event-emitter.js:61:33)\n    at [object Object].<anonymous> (/Users/me/Desktop/node/myapp/node_modules/sequelize/lib/emitters/custom-event-emitter.js:131:17)",
   "code":"42601"
},
"msg":"uncaughtException",
"time":"2014-03-31T14:17:29.496Z",
"v":0
}

What I am doing wrong?

Before I created dbname database in pg there was error missing database so I guess sequelize is connected to pg but it generates some syntax errors in pgsql code??


the problem was that in model schema I had Sequelize.INTEGER(11) - and postgres does not allow to pass 11 as a size of INTEGER - this will be solved in 2.x.x version of Sequelize (You can find issue corresponding to this problem on sequelize github repo).

1 Answer 1

0

Sequelize and postgres work well for me. Did you set dialect, protocol, port correctly in config.js like this

{
  "development":{
    "username":"name",
    "password":"pass",
    "database":"db",
    "dialect":"postgres",
    "protocol":"postgres",
    "host":"127.0.0.1",
    "port":"5432"
  },
...
Sign up to request clarification or add additional context in comments.

1 Comment

Sorry I forgot to write that this is solved - the problem was that in model schema I had Sequelize.INTEGER(11) - and postgres does not allow to pass 11 as a size of INTEGER - this will be solved in 2.x.x version of Sequelize (You can find issue corresponding to this problem on sequelize github repo).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.