From e873c5b7ed3c012b47a8b25f9acee55352c93537 Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Fri, 11 Nov 2022 14:49:51 +0100 Subject: [PATCH] ENH: change behavior of FIND * --- CHANGELOG.md | 2 ++ .../java/org/caosdb/server/query/Query.java | 17 +++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e65771c6..54d7e05d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 server property. * The new `FIND_QUERY_DEFAULT_ROLE` server property defaults to `RECORD` which is why the behavior of the server api has a **breaking change**. + * The semantics of `FIND *` are affected as well. `FIND *` is equivalent to + `FIND <FIND_QUERY_DEFAULT_ROLE>`. * Of course, administrators can choose to retain the old behavior by setting `FIND_QUERY_DEFAULT_ROLE=ENTITY`. diff --git a/src/main/java/org/caosdb/server/query/Query.java b/src/main/java/org/caosdb/server/query/Query.java index a517cbaa..1171aa05 100644 --- a/src/main/java/org/caosdb/server/query/Query.java +++ b/src/main/java/org/caosdb/server/query/Query.java @@ -596,16 +596,6 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac * </ol> */ public void optimize() { - // basic optimization - if (this.entity != null - && this.entity.type == Pattern.TYPE_LIKE - && this.entity.str.equals("*")) { - this.entity = null; - if (this.role == null) { - this.role = Role.ENTITY; - } - } - // "FIND Person" is interpreted as "FIND RECORD Person" if (this.role == null) { try { @@ -621,6 +611,13 @@ public class Query implements QueryInterface, ToElementable, TransactionInterfac throw new UnsupportedOperationException(e); } } + + // "FIND *" is interpreted as "FIND RECORD", "FIND <ROLE> *" as "FIND <ROLE>" + if (this.entity != null + && this.entity.type == Pattern.TYPE_LIKE + && this.entity.str.equals("*")) { + this.entity = null; + } } private String executeStrategy(final boolean versioned) throws QueryException { -- GitLab