gmunozfe commented on code in PR #2191:
URL: 
https://github.com/apache/incubator-kie-kogito-apps/pull/2191#discussion_r1956111600


##########
data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.1.0__metadata_as_column.sql:
##########
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ALTER TABLE definitions ADD COLUMN metadata varchar(max);
+
+/* Migration for postgresql and sql server
+ UPDATE definitions SET metadata = 
+(SELECT string_agg(name || '=' || meta_value, ',') FROM definitions_metadata 
where process_id = a.process_id and process_version = a.process_version) 
+FROM definitions_metadata as a
+WHERE process_id = a.process_id and process_version = a.process_version;
+*/
+
+
+/* Migration for h2 and oracle
+ UPDATE definitions SET metadata = 
+(SELECT listagg(name || '=' || meta_value, ',') FROM definitions_metadata 
where process_id = a.process_id and process_version = a.process_version) 
+FROM definitions_metadata as a
+WHERE process_id = a.process_id and process_version = a.process_version;
+*/
+
+/* Since migration is disable, do not delete not longer used table
+ * DROP TABLE definitions_metadata;*/

Review Comment:
   should we keep commented code?



##########
data-index/data-index-storage/data-index-storage-postgresql/src/main/java/org/kie/kogito/index/postgresql/PostgresqlJsonHelper.java:
##########
@@ -101,11 +105,26 @@ private static Expression 
buildObjectExpression(CriteriaBuilder builder, Object
 
     private static Expression buildPathExpression(CriteriaBuilder builder, 
Root<?> root, String attributeName, boolean isStr) {
         String[] attributes = attributeName.split("\\.");
-        Expression<?>[] arguments = new Expression[attributes.length];
-        arguments[0] = root.get(attributes[0]);
-        for (int i = 1; i < attributes.length; i++) {
-            arguments[i] = builder.literal(attributes[i]);
+
+        Collection<Expression> arguments = new ArrayList<>();
+        if (attributes.length == 1)
+            return root.get(attributeName);
+        int startIndex;
+        // Check if the first attribute is a join, if it is, assume next 
attribute is the json property (not sure thats necessarily correct but it will 
work)
+        try {
+            Join join = root.join(attributes[0]);

Review Comment:
   this a hack but will it work in some cases, for ex. when the first attribute 
is "joinable" but then (second attribute) there's something that doesn't admit 
to be joined (like a nested structure). Probably it's something out of the 
scope of this feature, but anticipating it for edge cases



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to