diff --git a/jnosql-communication/jnosql-communication-semistructured/src/main/java/org/eclipse/jnosql/communication/semistructured/QueryParser.java b/jnosql-communication/jnosql-communication-semistructured/src/main/java/org/eclipse/jnosql/communication/semistructured/QueryParser.java index 8d3e7468c..0eff5648b 100644 --- a/jnosql-communication/jnosql-communication-semistructured/src/main/java/org/eclipse/jnosql/communication/semistructured/QueryParser.java +++ b/jnosql-communication/jnosql-communication-semistructured/src/main/java/org/eclipse/jnosql/communication/semistructured/QueryParser.java @@ -12,6 +12,7 @@ import org.eclipse.jnosql.communication.QueryException; +import java.util.Locale; import java.util.Objects; import java.util.stream.Stream; @@ -69,6 +70,9 @@ public CommunicationPreparedStatement prepare(String query, String entity, Datab } private String extractQueryCommand(String query){ + if(query.length() < 6){ + return ""; + } return query.substring(0, 6).toUpperCase(); } @@ -76,8 +80,5 @@ private void validation(String query, DatabaseManager manager, CommunicationObse Objects.requireNonNull(query, "query is required"); Objects.requireNonNull(manager, "manager is required"); Objects.requireNonNull(observer, "manager is observer"); - if (query.length() < 6) { - throw new QueryException(String.format("The query %s is invalid", query)); - } } } \ No newline at end of file diff --git a/jnosql-mapping/jnosql-mapping-semistructured/src/test/java/org/eclipse/jnosql/mapping/semistructured/query/RepositoryProxyTest.java b/jnosql-mapping/jnosql-mapping-semistructured/src/test/java/org/eclipse/jnosql/mapping/semistructured/query/RepositoryProxyTest.java index 66da02d84..23ea22944 100644 --- a/jnosql-mapping/jnosql-mapping-semistructured/src/test/java/org/eclipse/jnosql/mapping/semistructured/query/RepositoryProxyTest.java +++ b/jnosql-mapping/jnosql-mapping-semistructured/src/test/java/org/eclipse/jnosql/mapping/semistructured/query/RepositoryProxyTest.java @@ -1036,6 +1036,9 @@ default Map> partcionate(String name) { @Query("FROM Person") Optional findByQuery(); + @Query(" ") + Optional all(); + @Query("FROM Person WHERE id = :id") Optional findByQuery(@Param("id") String id);