Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: gravsearch and count queries include deleted resources for some queries with negation patterns (DEV-2189) #2682

Merged
merged 3 commits into from
May 30, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,14 @@
case MinusPattern(_) +: Nil =>
ZIO
.fromOption(findMainResourceType(inputQuery))
.map(patterns.appended(_))
.map { statement =>
val notDeletedPattern = StatementPattern(
subj = statement.subj,
pred = IriRef(stringFormatter.toSmartIri(OntologyConstants.KnoraBase.IsDeleted)),
obj = XsdLiteral(value = "false", datatype = stringFormatter.toSmartIri(OntologyConstants.Xsd.Boolean))

Check warning on line 250 in webapi/src/main/scala/org/knora/webapi/messages/util/search/QueryTraverser.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/messages/util/search/QueryTraverser.scala#L247-L250

Added lines #L247 - L250 were not covered by tests
)
patterns.appendedAll(Seq(statement, notDeletedPattern))

Check warning on line 252 in webapi/src/main/scala/org/knora/webapi/messages/util/search/QueryTraverser.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/messages/util/search/QueryTraverser.scala#L252

Added line #L252 was not covered by tests
}
.orElseFail(
GravsearchOptimizationException(
s"Query consisted only of a MINUS pattern after optimization, which always returns empty results. Query: ${inputQuery.toSparql}"
Expand All @@ -252,7 +259,14 @@
case FilterNotExistsPattern(_) +: Nil =>
ZIO
.fromOption(findMainResourceType(inputQuery))
.map(patterns.appended(_))
.map { statement =>
val notDeletedPattern = StatementPattern(
subj = statement.subj,
pred = IriRef(stringFormatter.toSmartIri(OntologyConstants.KnoraBase.IsDeleted)),
obj = XsdLiteral(value = "false", datatype = stringFormatter.toSmartIri(OntologyConstants.Xsd.Boolean))

Check warning on line 266 in webapi/src/main/scala/org/knora/webapi/messages/util/search/QueryTraverser.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/messages/util/search/QueryTraverser.scala#L263-L266

Added lines #L263 - L266 were not covered by tests
)
patterns.appendedAll(Seq(statement, notDeletedPattern))

Check warning on line 268 in webapi/src/main/scala/org/knora/webapi/messages/util/search/QueryTraverser.scala

View check run for this annotation

Codecov / codecov/patch

webapi/src/main/scala/org/knora/webapi/messages/util/search/QueryTraverser.scala#L268

Added line #L268 was not covered by tests
}
.orElseFail(
GravsearchOptimizationException(
s"Query consisted only of a FILTER NOT EXISTS pattern after optimization, which always returns empty results. Query: ${inputQuery.toSparql}"
Expand Down