0

When query execution fails (for example database constraint violation on saving) i can see in console.

Should be empty: []

Here is the example (you can see Should be empty: [] in console)):

 breeze.EntityQuery
     .from("EntityThatDoesnotExist")
     .using(new breeze.EntityManager("http://todo.breezejs.com/api/todos"))
     .execute()
     .then(function () { })
     .fail(function () { });

http://jsfiddle.net/vMhkg/3/

I'm new to Breeze and Q, so my question is: should I just just ignore this? Or am I doing something wrong? Or might it be just a bug to report?

The Smallest
  • 5,713
  • 25
  • 38

2 Answers2

1

Actually I don't think that this is a bug.

This is actually the "as designed" behaviour of Q ( the promises library that breeze uses) in the case where a promise chain is not terminated with a done() or end() call.

from this link: https://groups.google.com/forum/#!topic/q-continuum/TfV8TIYaCpc

The message should only every be written to the console in a browser, the first time a rejected promise is constructed. It is a mechanism to prevent unhandled rejections from going unnoticed, which can happen if the programmer forgets to terminate a chain of promises with .done(), .end(), or .nodeify(). Unfortunately, once the message has been written to the console, it cannot be removed. However, the browser console provides a living view into the content of the array. When the rejection gets handled, Q removes the "reason" from the array. Thus, if you see Should be empty: [] on your console, nothing is wrong.

Also, in the interest of completeness, if you were to actually handle the fail case, you will get a meaningful error message in e.message, i.e.

breeze.EntityQuery
     .from("EntityThatDoesnotExist")
     .using(new breeze.EntityManager("http://todo.breezejs.com/api/todos"))
     .execute()
     .then(function () { 
        // will not get here.
     }) .fail(function (e) { 
        // e.message will contain a message something like: 
        //   No HTTP resource was found that matches the request URI  
        //   http://localhost:7149/api/NorthwindIBModel/EntityThatDoesnotExist'
});
Jay Traband
  • 17,053
  • 1
  • 23
  • 44
  • Thanks for answer. One more question: I submitted issue to github (abut extended properties sent back to server), but recently issues were disabled. If there any option to know the state of that issue? – The Smallest Mar 19 '13 at 11:01
  • Sorry about that, we are still trying to work out the best policies for handling these requests. Could I get you repost the question here? and thx... – Jay Traband Mar 19 '13 at 17:13
  • It was reposted: http://stackoverflow.com/questions/15508233/1-2-1-unmapped-properties-shouldnt-be-serialized – The Smallest Mar 19 '13 at 23:11
0

This is a complete long shot here. I just ran into this same error within the last 2 hours and was quite confused. I ended up debugging into breeze.debug.js and discovered that I had an invalid date that I was trying to save. Once I corrected the date issue (converted everything to UTC), the Should be empty:[] message went away. Anyway, I could see the actual validation that was failing in the validateTarget method in Breeze at line 3604, the actual check was performed at line 3615.

Not sure if this will help you at all, but being I just saw the same error, I figured it would hurt to share my experience.

Just for reference, here is the validation method I debugged for more information.

     function validateTarget(target) {
        var ok = true;
        var stype = target.entityType || target.complexType;
        var aspect = target.entityAspect || target.complexAspect;
        var entityAspect = target.entityAspect || target.complexAspect.entityAspect;

        stype.getProperties().forEach(function (p) {
            var value = target.getProperty(p.name);
            var propName = aspect.propertyPath ? aspect.propertyPath + "." + p.name : p.name;
            if (p.validators.length > 0) {
                var context = { entity: entityAspect.entity, property: p, propertyName: propName };
                ok = entityAspect._validateProperty(value, context) && ok; //This is where I put my break point to see what was actually failing.
            }
            if (p.isComplexProperty) {
                ok = validateTarget(value) && ok;
            }
        });
Jay
  • 51
  • 4