2014-03-31 52 views
0
sequelize: 1.7.0 
pg: 2.11.1 
posgreSql: 9.3 (pg server on my pc) 

我有一個使用以下配置應用程序中的語法錯誤。 當我將其更改爲:使用sequelize如果postgres

db: 'postgres://user:[email protected]/dbname' 

和方言postgres,並嘗試sequelize.sync()我獲得以下錯誤:

{ 
    "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 
} 

我做錯了嗎?

在我創建dbname數據庫在pg之前有錯誤missing database所以我猜sequelize連接到pg但它會在pgsql代碼中產生一些語法錯誤?


的問題是,在模型模式,我不得不Sequelize.INTEGER(11) - 和Postgres不允許通過11作爲大小INTEGER的 - 這將在2.xx的版本Sequelize的(你可以解決可以在sequelize github repo上找到與這個問題相對應的問題)。

回答

0

續集和postgres適合我。你喜歡這個

{ 
    "development":{ 
    "username":"name", 
    "password":"pass", 
    "database":"db", 
    "dialect":"postgres", 
    "protocol":"postgres", 
    "host":"127.0.0.1", 
    "port":"5432" 
    }, 
... 
+1

對不起,我忘了寫,這是解決正確config.js設置方言,協議,端口 - 問題是,在模型模式,我有'Sequelize.INTEGER(11)' - 和postgres不允許將'11'作爲INTEGER的大小傳遞 - 這將在Sequelize的'2.xx'版本中解決(你可以在sequelize github repo上找到與這個問題相對應的問題)。 – user606521

相關問題