Torque
  1. Torque
  2. TORQUE-178

Change semantics of add() and or() methods in Criteria

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 4.0-beta1
    • Component/s: Runtime, Templates
    • Labels:
      None

      Description

      In my opinion, the Criteria.add() and Criteria.or() method behave counter-intuitively. My opinion of an intuitive behaviour would be:

      • Criteria.or(someCondition) should result in a where clause which contains ((whatever was in the where condition before) OR someCondition)
      • Criteria.add(someCondition) should result in a where clause which contains ((whatever was in the where condition before) AND someCondition), i.e. the same as Criteria.and(someCondition)

      Instead, the behaviour is now

      • Criteria.or(someCondition) only or's the new condition with any existing condition(s) that affects the same column.
      • Criteria.add(someCondition) replaces any existing condition(s) that affects the same column with the new condition.

        Activity

        Hide
        Thomas Fox added a comment -

        also done the following

        • use both criteria classes in BasePeer, SQLBuilder, CountHelper and SummaryHelper
        • make configurable which Criteria class to use in the templates. Default is the new class. Config parameters are:
          torque.om.criteriaClass = org.apache.torque.criteria.Criteria
          torque.om.criterionClass = org.apache.torque.criteria.Criterion
        • adjusted the test project to use the new class.
          Currently, there is no easy way to run the test project against the old criteria class. will do some copy and paste to cover basic functionality of the old criteria class.
        Show
        Thomas Fox added a comment - also done the following use both criteria classes in BasePeer, SQLBuilder, CountHelper and SummaryHelper make configurable which Criteria class to use in the templates. Default is the new class. Config parameters are: torque.om.criteriaClass = org.apache.torque.criteria.Criteria torque.om.criterionClass = org.apache.torque.criteria.Criterion adjusted the test project to use the new class. Currently, there is no easy way to run the test project against the old criteria class. will do some copy and paste to cover basic functionality of the old criteria class.
        Hide
        Thomas Fox added a comment -

        As discussed in the mailing list, the old behaviour should be unchanged but the old util.Criteria object should keep its old behaviour but become deprecated. The old class will be removed in Torque 4.1.
        A new package org.apache.torque.criteria should be created. A new Criteria class should be created therein which has the new behaviour.

        Show
        Thomas Fox added a comment - As discussed in the mailing list, the old behaviour should be unchanged but the old util.Criteria object should keep its old behaviour but become deprecated. The old class will be removed in Torque 4.1. A new package org.apache.torque.criteria should be created. A new Criteria class should be created therein which has the new behaviour.

          People

          • Assignee:
            Thomas Fox
            Reporter:
            Thomas Fox
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development