coresmart / persistencejs

persistence.js is an asynchronous Javascript database mapper library. You can use it in the browser, as well on the server (and you can share data models between them).
http://persistencejs.org
1.73k stars 240 forks source link

TypeError: Cannot read property 'prototype' of undefined #47

Closed mjadobson closed 13 years ago

mjadobson commented 13 years ago

I installed persistence.js today with npm. I firstly encountered the issue here: https://github.com/zefhemel/persistencejs/issues/39 , but fixed it by linking to the files in my "app.js" thusly:

var persistence = require("persistencejs/persistence.min").persistence,
    persistenceStore = require("persistencejs/lib/persistence.store.mysql");

Then I tried running my app again and node coughed up this error:

TypeError: Cannot read property 'prototype' of undefined
    at Object.config (/home/matt/node_modules/persistencejs/lib/persistence.store.sql.js:532:23)
    at Object.config (/home/matt/node_modules/persistencejs/lib/persistence.store.mysql.js:122:7)
    at Object.<anonymous> (/home/matt/Sites/Test/app.js:18:18)
    at Module._compile (module.js:404:26)
    at Object..js (module.js:410:10)
    at Module.load (module.js:336:31)
    at Function._load (module.js:297:12)
    at Array.<anonymous> (module.js:423:10)
    at EventEmitter._tickCallback (node.js:170:26)

Digging into this, it appears that persistence.OrFilter is undefined, although my brief look through the source would indicate that it should be defined. NullFilter, AndFilter & PropertyFilter all seem to be defined according to console.log(persistence);, so I do not understand why this particularly property isn't working.

Commenting out lines 532->535 of persistence.store.sql.js stops the error, but I assume that would break functionality.

/*persistence.OrFilter.prototype.sql = function (meta, alias, values) {
    return "(" + this.left.sql(meta, alias, values) + " OR "
    + this.right.sql(meta, alias, values) + ")";
};*/

Has anyone else encountered this issue?

npm: 1.0.6, node: v0.5.0-pre, persistencejs: 0.2.5.

mjadobson commented 13 years ago

My bad. This gives no errors:

var persistence = require("persistencejs/lib/persistence").persistence,
    persistenceStore = require("persistencejs/lib/persistence.store.mysql");

I was just linking incorrectly.