evitaDB icon indicating copy to clipboard operation
evitaDB copied to clipboard

Requirement `referenceContent` doesn't correctly work with `entityLocaleEquals` sub-constraint

Open novoj opened this issue 5 months ago • 0 comments

The problem can be seen in test io.evitadb.api.EntityFetchingFunctionalTest#shouldEagerlyDeepFetchReferenceEntityBodiesFilteredAndOrderedViaGetEntity, when following query is used:

final SealedEntity product = session.getEntity(
	Entities.PRODUCT,
	productsWithLotsOfStores.keySet().iterator().next(),
	referenceContent(
		Entities.STORE,
		filterBy(
			entityPrimaryKeyInSet(filteredStores),
			entityLocaleEquals(LOCALE_CZECH),
			entityHaving(
				and(
					entityPrimaryKeyInSet(filteredStores),
					entityLocaleEquals(LOCALE_CZECH)
				)
			)
		),
		orderBy(
			entityProperty(
				attributeNatural(ATTRIBUTE_NAME, OrderDirection.DESC)
			)
		),
		entityFetch(attributeContent(), associatedDataContentAll())
	)
).orElseThrow();

Current test is not written correctly and passes only by a chance. When you apply correct query as in this issue ordering fails because the entity locale from the filter part is not recognized.

Also we should consider dropping requirement for single constraint in entityHaving and support var arg input (we need also to verify ANTLR definition for this constraint).

novoj avatar Jul 24 '25 05:07 novoj