spring-data-mongodb icon indicating copy to clipboard operation
spring-data-mongodb copied to clipboard

Add support for CriteriaDefinition on $or operator

Open alxxyz opened this issue 2 years ago • 2 comments

Currently in Criteria class we have the method

public Criteria orOperator(Criteria... criteria) {
		BasicDBList bsonList = createCriteriaList(criteria);
		return registerCriteriaChainElement(new Criteria("$or").is(bsonList));
	}

This can be changed to

public Criteria orOperator(CriteriaDefinition... criteria) {
		BasicDBList bsonList = createCriteriaList(criteria);
		return registerCriteriaChainElement(new Criteria("$or").is(bsonList));
	}

In this case it will be more flexible, and also it will be possible to have Criteria and TextCriteria mixed in $or operator.

alxxyz avatar Dec 02 '21 09:12 alxxyz

I might be wrong, but I don't think this is ideal, Criteria being a concrete class if supports an interface type as parameter while returning a concrete instance of Criteria again means the relation of Criteria and TextCriteria is not sibling.

thekaleidoscope avatar May 15 '22 14:05 thekaleidoscope

@christophstrobl do we want to do this change? Everywhere inside the Criteria class we use Criteria as a parameter. If we want to support CriteriaDefinition, we will allow to to use all implementations and mix the CriteriasDefinitions implementations. We would have to update all the methods, not just this one

tudormarc avatar May 25 '22 19:05 tudormarc