我无法用postgresql版本0.9.7来提升0.9.9版本的风帆
这是我得到的错误消息
调试:降下帆..。
/home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/query.js:285
if(self._schema[key].type === 'text') caseSensitive = false;
^
TypeError: Cannot read property 'type' of undefined
at Object.sql.and (/home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/query.js:285:27)
at /home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/query.js:256:19
at Array.forEach (native)
at [object Object].Query.where (/home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/query.js:195:24)
at /home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/query.js:119:14
at Array.forEach (native)
at [object Object].Query._build (/home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/query.js:115:32)
at [object Object].Query.find (/home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/query.js:35:21)
at __FIND__ (/home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/adapter.js:362:40)
at after (/home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/adapter.js:506:7)
at /home/mandeep/iqr/thirstt/node_modules/sails-postgresql/lib/adapter.js:492:7之前还挺好的。不知道哪里出了问题。我已经尝试删除node_modules目录,并在npm cache clear之后执行npm install,但是仍然会继续得到这个错误。我不能升级到0.10,因为它是一个相当大的项目,升级将是一个非常大的努力。如何在同一版本中解决此问题?任何帮助都将不胜感激。
发布于 2014-11-06 08:22:05
我解决了这个问题。对我来说就像个帆-postgresql问题。我在config/bootstrap.js中的一个模型上做了一个findOne,当那个表中没有记录时,它失败了。
下面是它失败的部分( node_modules/sails-postgresql/lib/query.js ):
Query.prototype.operators = function() {
var self = this;
var sql = {
and: function(key, options, comparator) {
var caseSensitive = true;
// Check if key is a string
if(self._schema[key].type === 'text') caseSensitive = false;
processCriteria.call(self, key, options, '=', caseSensitive);
self._query += (comparator || ' AND ');
},我记录了self的价值。当数据存在于我在bootstrap.js中查询的表中时,self如下所示
{ _values:
[ 2,
1,
'Mon, 29 Sep 2014 09:46:08 GMT',
'Thu, 06 Nov 2014 08:24:34 GMT' ],
_paramCount: 5,
_query: 'UPDATE "cache" SET "val" = $1, "id" = $2, "createdAt" = $3, "updatedAt" = $4 ',
_schema:
{ val: { type: 'integer' },
id: { type: 'integer', primaryKey: true, autoIncrement: true },
createdAt: { type: 'timestamp with time zone' },
updatedAt: { type: 'timestamp with time zone' } }
}但是,当表中没有数据时,self如下所示
{ _values: [],
_paramCount: 1,
_query: 'SELECT * FROM "cache" ',
_schema: true
}然后访问self._schemakey.type,这会引发错误,因为在这种情况下,self._schema不是一个对象。在将数据插入到表中时,事情得到了修正,但我认为它是sails中的一个逻辑错误-postgresql,因为即使表中没有数据,它也应该工作得很好。
https://stackoverflow.com/questions/26752292
复制相似问题