Search code examples
sqlnullbreezepredicate

Breeze predicate: column = null vs column IS NULL


Can breeze predicate test for null column? SQL test for null in two ways: columnname = null and columnname IS NULL, which generate different results. I have a breeze predicate set as

new breeze.Predicate("columnname", "==", null)

Using EF6 interceptors, I am able to view the sql query used and the predicate is evaluated as columnname = null. How do I set a predicate such that the sql query generated will be columnname IS NULL


Solution

  • Have you read the docs? http://breeze.github.io/doc-js/api-docs/classes/Predicate.html#method_ Predicate

    One of the examples

    var p2 = new Predicate("Region", FilterQueryOp.Equals, null);
    

    More docs, with your answer, on FilterQueryOp: http://breeze.github.io/doc-js/api-docs/classes/FilterQueryOp.html#property_Equals

    This shows that you can do == fine for null equality. It also shows that there is no "IS NULL" option, so to answer your question, no you can not do "is null" from the breeze client side predicate.

    However, you should note that this is client side, I believe you will need to evaluate your server side code more to find out where it is processing the breeze request and transforming it into SQL.