No announcement yet.
  • Filter
  • Time
Clear All
new posts

    Easy but valuable server enhancement: false-Criterion

    Hi Isomorphic,

    I find myself often in the situation where I do other requests in a server DMI to amend the original request with additional criteria.

    Sometimes it turns out that the user is allowed to do something (e.g. show the contents of a dropdown), but that the list should actually be empty.
    So far, I did this by amending the criteria with PK_field = -1 (my PK_field is a sequence, so this is not possible and will return 0 rows when executed).

    The problem is: The database might or might not realize this (Oracle does if it has statistics, but this is not necessarily true for every database) and actually try to fetch data.
    Also this looks like a workaround. If I could amend '0' = '1' criteria, this can be short-circuit evaluated to false by every RDBMS.

    I know that you generate these criteria for e.g. a inSet operator with an empty set. But using this would not be declarative IMHO.

    Can you add a FalseCriterion (or NoDataCriterion) to com.isomorphic.criteria.criterion that always becomes '0' = '1'?

    I don't have an use case for this on the clientside, but perhaps it is a valuable addition there as well.

    This has no priority for me.

    Thank you & Best regards

    Interesting idea, but with an already-long list of operators, we don't really want to add yet more. Using the inSet operator is a good approach, and you can make your code clearer by creating a helper method getFalseCriterion() which returns an inSet operator and no list.