Turn off caching

This commit is contained in:
Anatoliy Chakkaev 2012-04-11 19:36:10 +04:00
parent 87a8172b82
commit df57805b94
2 changed files with 7 additions and 3 deletions

View File

@ -658,6 +658,7 @@ AbstractClass.hasMany = function hasMany(anotherClass, params) {
function find(id, cb) {
anotherClass.find(id, function (err, inst) {
if (err) return cb(err);
if (!inst) return cb(new Error('Not found'));
if (inst[fk] == this.id) {
cb(null, inst);
} else {
@ -863,6 +864,7 @@ function defineReadonlyProp(obj, key, value) {
* Add object to cache
*/
function addToCache(constr, obj) {
return;
touchCache(constr, obj.id);
constr.cache[obj.id] = obj;
}

View File

@ -234,13 +234,14 @@ function testOrm(schema) {
post.save(function () {
test.ok(post.a);
post.reload(function (err, psto) {
test.ok(!post.a);
test.ok(!psto.a);
test.done();
});
});
});
});
/*
it('should not create new instances for the same object', function (test) {
var title = 'Initial title';
Post.create({ title: title }, function (err, post) {
@ -254,6 +255,7 @@ function testOrm(schema) {
});
});
});
*/
it('should not re-instantiate object on saving', function (test) {
var title = 'Initial title';
@ -311,7 +313,7 @@ function testOrm(schema) {
test.ok(!post.propertyChanged('title'));
test.equal(post.content, 'New content', 'dirty state saved');
test.ok(post.propertyChanged('content'));
post.reload(function () {
post.reload(function (err, post) {
test.equal(post.title, 'New title');
test.ok(!post.propertyChanged('title'));
test.equal(post.content, 'content', 'real value turned back');
@ -401,7 +403,7 @@ function testOrm(schema) {
if (err) return console.log(err);
// test.ok(post.author(), u.id);
u.posts(function (err, posts) {
test.strictEqual(posts.pop(), post);
test.strictEqual(posts.pop().id, post.id);
test.done();
});
});