Question

I have a where clause that basically splits my table into two lists. One list where all the fields are "complete"(Not -1) and then one where any field is incomplete. The problem is that one of these fields is not only nullable, but I also only want to count it as incomplete if another field is true.

Where clause:

//l and p are my two tables(This is in a join)
//passed in an option incompletes. If incompletes is true, give back incomplete values
where(
  //SHOW INCOMPLETES
  (
    p.attr1 === -1 or
    p.attr2 === -1 or
    p.attr3 === -1 or
    //only need to check attr4 if this var is true
    (p.attr4 === -1).inhibitWhen(!l.needToCheckAttr4) //I've also tried === Some(-1)
    ).inhibitWhen(!incompletes.isDefined) and
  // SHOW COMPLETES
  (
    p.price <> -1 and
    p.serverCost <> -1 and
    p.depreciation <> -1 and
    (p.attr4 <>  -1).inhibitWhen(!l.needToCheckAttr4)
    ).inhibitWhen(incompletes.isDefined)
  )

The attr4 lines seem to have no effect while the rest of the conditions all work correctly. That is as long as the other conditions are true it renders as complete.

EDIT : So it's definitely something to do with calling the inhibitWhen. Is there something wrong with using two different tables in the one line(l and p)?

Was it helpful?

Solution

Okay so I just gave up on the inhibitWhen and used

(p.attr4 === -1 and l.needToCheckAttr4 === true)

and...

((p.attr4 <>  -1 and l.needToCheckAttr4 === true) or (l.needToCheckAttr4 === false))

which I probably should have done in the first place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top