From 839c45f54578bc10f826fce44460ca7963062494 Mon Sep 17 00:00:00 2001 From: Deepak Joseph <159427631+josedee@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:21:41 +0530 Subject: [PATCH] [kie-issues#1606] Modify columns in the flyway migration scripts which uses sql reserved words (#2139) * Modified column names with reserved words Signed-off-by: Deepak Joseph * Fixed most tests Signed-off-by: Deepak Joseph * Fixed tests Signed-off-by: Deepak Joseph * Fixed column name Signed-off-by: Deepak Joseph * Updated the column names after KIE discussions * Fixed tests * To rerun --------- Signed-off-by: Deepak Joseph --- .../kogito/index/jpa/model/NodeEntity.java | 4 ++-- .../jpa/model/ProcessDefinitionEntity.java | 6 ++--- ....7__modify_columns_with_reserved_words.sql | 24 +++++++++++++++++++ ....7__modify_columns_with_reserved_words.sql | 24 +++++++++++++++++++ .../persistence/postgresql/PostgresQuery.java | 2 +- .../postgresql/model/CacheEntity.java | 8 +++---- ....1__modify_columns_with_reserved_words.sql | 21 ++++++++++++++++ .../main/resources/cache_entity_create.sql | 7 +++--- ....1__modify_columns_with_reserved_words.sql | 21 ++++++++++++++++ .../README.md | 16 ++++++------- .../src/test/resources/bootstrap.json | 12 +++++----- .../reporting/BasicTypeMappingIT.java | 10 ++++---- .../ComplexHierarchicalTypeMappingIT.java | 10 ++++---- .../reporting/HierarchicalTypeMappingIT.java | 10 ++++---- .../api/PostgresMappingsApiV1IT.java | 4 ++-- .../PostgresApplyMappingSqlBuilderIT.java | 14 +++++------ .../src/test/resources/bootstrap.json | 12 +++++----- 17 files changed, 148 insertions(+), 57 deletions(-) create mode 100644 data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.7__modify_columns_with_reserved_words.sql create mode 100644 data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.7__modify_columns_with_reserved_words.sql create mode 100644 persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.1__modify_columns_with_reserved_words.sql create mode 100644 persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql/V1.5.1__modify_columns_with_reserved_words.sql diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java index 7eaab4dfd1..f11c3d2b47 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/NodeEntity.java @@ -53,8 +53,8 @@ public class NodeEntity extends AbstractEntity { @CollectionTable(name = "definitions_nodes_metadata", joinColumns = { @JoinColumn(name = "node_id", referencedColumnName = "id"), @JoinColumn(name = "process_id", referencedColumnName = "process_id"), @JoinColumn(name = "process_version", referencedColumnName = "process_version") }, foreignKey = @ForeignKey(name = "fk_definitions_nodes_metadata_definitions_nodes")) - @MapKeyColumn(name = "key") - @Column(name = "value") + @MapKeyColumn(name = "name") + @Column(name = "meta_value") private Map metadata; @Id diff --git a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java index 100dc79c16..a7158f31bb 100644 --- a/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java +++ b/data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/model/ProcessDefinitionEntity.java @@ -72,14 +72,14 @@ public class ProcessDefinitionEntity extends AbstractEntity { @ElementCollection @CollectionTable(name = "definitions_annotations", joinColumns = { @JoinColumn(name = "process_id", referencedColumnName = "id"), @JoinColumn(name = "process_version", referencedColumnName = "version") }, foreignKey = @ForeignKey(name = "fk_definitions_annotations")) - @Column(name = "value") + @Column(name = "annotation") private Set annotations; @ElementCollection @CollectionTable(name = "definitions_metadata", joinColumns = { @JoinColumn(name = "process_id", referencedColumnName = "id"), @JoinColumn(name = "process_version", referencedColumnName = "version") }, foreignKey = @ForeignKey(name = "fk_definitions_metadata")) - @MapKeyColumn(name = "key") - @Column(name = "value") + @MapKeyColumn(name = "name") + @Column(name = "meta_value") private Map metadata; @Override diff --git a/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.7__modify_columns_with_reserved_words.sql b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.7__modify_columns_with_reserved_words.sql new file mode 100644 index 0000000000..fd92ea6208 --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-jpa/src/main/resources/kie-flyway/db/data-index/ansi/V1.45.0.7__modify_columns_with_reserved_words.sql @@ -0,0 +1,24 @@ +/* + * 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_nodes_metadata alter column key rename to name; +alter table definitions_nodes_metadata alter column value rename to meta_value; +alter table definitions_metadata alter column key rename to name; +alter table definitions_metadata alter column value rename to meta_value; +alter table definitions_annotations alter column value rename to annotation; diff --git a/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.7__modify_columns_with_reserved_words.sql b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.7__modify_columns_with_reserved_words.sql new file mode 100644 index 0000000000..342cacedff --- /dev/null +++ b/data-index/data-index-storage/data-index-storage-postgresql/src/main/resources/kie-flyway/db/data-index/postgresql/V1.45.0.7__modify_columns_with_reserved_words.sql @@ -0,0 +1,24 @@ +/* + * 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_nodes_metadata rename column key to name; +alter table definitions_nodes_metadata rename column value to meta_value; +alter table definitions_metadata rename column key to name; +alter table definitions_metadata rename column value to meta_value; +alter table definitions_annotations rename column value to annotation; diff --git a/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java index ae831210ee..d173148941 100644 --- a/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java +++ b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/PostgresQuery.java @@ -117,7 +117,7 @@ public List execute() { // Build the query to retrieve the filtered data from the temporary table above. StringBuilder queryString = new StringBuilder("SELECT * FROM kogito_data_cache") - .append(" WHERE name = '") + .append(" WHERE cache_name = '") .append(name) .append("'"); if (filters != null && !filters.isEmpty()) { diff --git a/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java index 0fac442af7..cde1d5471a 100644 --- a/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java +++ b/persistence-commons/persistence-commons-jpa-base/src/main/java/org/kie/kogito/persistence/postgresql/model/CacheEntity.java @@ -35,16 +35,16 @@ @Entity @IdClass(CacheId.class) -@Table(name = "kogito_data_cache", uniqueConstraints = @UniqueConstraint(columnNames = { "name", - "key" }), indexes = @Index(columnList = "name,key", unique = true)) +@Table(name = "kogito_data_cache", uniqueConstraints = @UniqueConstraint(columnNames = { "cache_name", + "var_name" }), indexes = @Index(columnList = "cache_name,var_name", unique = true)) public class CacheEntity { @Id - @Column(nullable = false) + @Column(name = "cache_name", nullable = false) private String name; @Id - @Column(nullable = false) + @Column(name = "var_name", nullable = false) private String key; @Convert(converter = JsonBinaryConverter.class) diff --git a/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.1__modify_columns_with_reserved_words.sql b/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.1__modify_columns_with_reserved_words.sql new file mode 100644 index 0000000000..49b4397939 --- /dev/null +++ b/persistence-commons/persistence-commons-jpa/src/main/resources/kie-flyway/db/persistence-commons/ansi/V1.5.1__modify_columns_with_reserved_words.sql @@ -0,0 +1,21 @@ +/* + * 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 kogito_data_cache alter column name rename to cache_name; +alter table kogito_data_cache alter column key rename to var_name; diff --git a/persistence-commons/persistence-commons-postgresql/src/main/resources/cache_entity_create.sql b/persistence-commons/persistence-commons-postgresql/src/main/resources/cache_entity_create.sql index b152f39073..1b45067877 100644 --- a/persistence-commons/persistence-commons-postgresql/src/main/resources/cache_entity_create.sql +++ b/persistence-commons/persistence-commons-postgresql/src/main/resources/cache_entity_create.sql @@ -19,8 +19,9 @@ create table if not exists kogito_data_cache ( - key varchar(255) not null, - name varchar(255) not null, + var_name varchar(255) not null, + cache_name varchar(255) not null, json_value jsonb, - primary key (key, name) + primary key (var_name, cache_name) ); + diff --git a/persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql/V1.5.1__modify_columns_with_reserved_words.sql b/persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql/V1.5.1__modify_columns_with_reserved_words.sql new file mode 100644 index 0000000000..9c74443e8b --- /dev/null +++ b/persistence-commons/persistence-commons-postgresql/src/main/resources/kie-flyway/db/persistence-commons/postgresql/V1.5.1__modify_columns_with_reserved_words.sql @@ -0,0 +1,21 @@ +/* + * 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 kogito_data_cache rename column name to cache_name; +alter table kogito_data_cache rename column key to var_name; diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-api/README.md b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-api/README.md index c3298916b9..698d157ab3 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-api/README.md +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-api/README.md @@ -114,8 +114,8 @@ The following limitations apply: All examples assume the following schema: ```postgresql create table kogito_data_cache ( - key varchar(255) not null, - name varchar(255) not null, + var_name varchar(255) not null, + cache_name varchar(255) not null, json_value jsonb, primary key (key, name) ); @@ -130,13 +130,13 @@ entities through JPA. There are code examples in `org.kie.kogito:persistence-com "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName":"key", + "fieldName":"var_name", "fieldType": "STRING" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldType": "STRING", "fieldValue": "BasicType" } @@ -186,13 +186,13 @@ Result "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName":"key", + "fieldName":"var_name", "fieldType": "STRING" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldType": "STRING", "fieldValue": "HierarchicalType" } @@ -265,13 +265,13 @@ Result "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName":"key", + "fieldName":"var_name", "fieldType": "STRING" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldType": "STRING", "fieldValue": "ComplexHierarchicalType" } diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-base/src/test/resources/bootstrap.json b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-base/src/test/resources/bootstrap.json index 6b7b8db0a6..bffad3405b 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-base/src/test/resources/bootstrap.json +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-base/src/test/resources/bootstrap.json @@ -6,13 +6,13 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName":"key", + "fieldName":"var_name", "fieldType": "STRING" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldType": "STRING", "fieldValue": "BasicType" } @@ -41,13 +41,13 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName":"key", + "fieldName":"var_name", "fieldType": "STRING" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldType": "STRING", "fieldValue": "HierarchicalType" } @@ -83,13 +83,13 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName":"key", + "fieldName":"var_name", "fieldType": "STRING" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldType": "STRING", "fieldValue": "ComplexHierarchicalType" } diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/BasicTypeMappingIT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/BasicTypeMappingIT.java index 69db207deb..8a93c264c7 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/BasicTypeMappingIT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/BasicTypeMappingIT.java @@ -49,9 +49,9 @@ class BasicTypeMappingIT { private static final String CACHE_NAME = "BasicType"; private static final String SQL = "SELECT " + - "ROW_NUMBER() OVER (ORDER BY name, key) as id, " + - "name, " + - "key, " + + "ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " + + "cache_name, " + + "var_name, " + "field1MappedField, " + "field2MappedField " + "FROM " + @@ -174,8 +174,8 @@ private void assertResultSize(final int expected) { @EntityResult( entityClass = BasicTypeExtractRow.class, fields = { @FieldResult(name = "id", column = "id"), - @FieldResult(name = "key", column = "key"), - @FieldResult(name = "name", column = "name"), + @FieldResult(name = "key", column = "var_name"), + @FieldResult(name = "name", column = "cache_name"), @FieldResult(name = "field1MappedField", column = "field1MappedField"), @FieldResult(name = "field2MappedField", column = "field2MappedField") }) }) diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/ComplexHierarchicalTypeMappingIT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/ComplexHierarchicalTypeMappingIT.java index 9000224538..7bf4292c1f 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/ComplexHierarchicalTypeMappingIT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/ComplexHierarchicalTypeMappingIT.java @@ -50,9 +50,9 @@ class ComplexHierarchicalTypeMappingIT { private static final String CACHE_NAME = "ComplexHierarchicalType"; private static final String SQL = "SELECT " + - "ROW_NUMBER() OVER (ORDER BY name, key) as id, " + - "name, " + - "key, " + + "ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " + + "cache_name, " + + "var_name, " + "root, " + "nestedBasicMappedField, " + "nestedComplexCollectionMappedField1, " + @@ -210,8 +210,8 @@ private void assertResultSize(final int expected) { @EntityResult( entityClass = ComplexHierarchicalTypeExtractRow.class, fields = { @FieldResult(name = "id", column = "id"), - @FieldResult(name = "key", column = "key"), - @FieldResult(name = "name", column = "name"), + @FieldResult(name = "key", column = "var_name"), + @FieldResult(name = "name", column = "cache_name"), @FieldResult(name = "root", column = "root"), @FieldResult(name = "nestedBasicMappedField", column = "nestedBasicMappedField"), @FieldResult(name = "nestedComplexCollectionMappedField1", column = "nestedComplexCollectionMappedField1"), diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/HierarchicalTypeMappingIT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/HierarchicalTypeMappingIT.java index f671db43fb..5ad3c00ae8 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/HierarchicalTypeMappingIT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/HierarchicalTypeMappingIT.java @@ -49,9 +49,9 @@ class HierarchicalTypeMappingIT { private static final String CACHE_NAME = "HierarchicalType"; private static final String SQL = "SELECT " + - "ROW_NUMBER() OVER (ORDER BY name, key) as id, " + - "name, " + - "key, " + + "ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " + + "cache_name, " + + "var_name, " + "root, " + "nestedBasicMappedField, " + "nestedBasicCollectionMappedField " + @@ -194,8 +194,8 @@ private void assertResultSize(final int expected) { @EntityResult( entityClass = HierarchicalTypeExtractRow.class, fields = { @FieldResult(name = "id", column = "id"), - @FieldResult(name = "key", column = "key"), - @FieldResult(name = "name", column = "name"), + @FieldResult(name = "key", column = "var_name"), + @FieldResult(name = "name", column = "cache_name"), @FieldResult(name = "root", column = "root"), @FieldResult(name = "nestedBasicMappedField", column = "nestedBasicMappedField"), @FieldResult(name = "nestedBasicCollectionMappedField", column = "nestedBasicCollectionMappedField") }) diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/api/PostgresMappingsApiV1IT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/api/PostgresMappingsApiV1IT.java index 124380608b..38767dd53d 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/api/PostgresMappingsApiV1IT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/api/PostgresMappingsApiV1IT.java @@ -72,8 +72,8 @@ void dynamicMappingDefinitionCreation() { final PostgresMappingDefinition definition = new PostgresMappingDefinition("ExampleMappingId", "kogito_data_cache", "json_value", - List.of(new PostgresField("key")), - List.of(new PostgresPartitionField("name", "Example")), + List.of(new PostgresField("var_name")), + List.of(new PostgresPartitionField("cache_name", "Example")), "Example", List.of(new PostgresMapping("field1", new PostgresJsonField("field1", JsonType.STRING)))); diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/database/sqlbuilders/PostgresApplyMappingSqlBuilderIT.java b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/database/sqlbuilders/PostgresApplyMappingSqlBuilderIT.java index 43511ef5a2..efb4ba5804 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/database/sqlbuilders/PostgresApplyMappingSqlBuilderIT.java +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/java/org/kie/kogito/persistence/postgresql/reporting/database/sqlbuilders/PostgresApplyMappingSqlBuilderIT.java @@ -55,9 +55,9 @@ class PostgresApplyMappingSqlBuilderIT { private static final String CACHE_NAME = "DynamicType"; private static final String SQL = "SELECT " + - "ROW_NUMBER() OVER (ORDER BY name, key) as id, " + - "name, " + - "key, " + + "ROW_NUMBER() OVER (ORDER BY cache_name, var_name) as id, " + + "cache_name, " + + "var_name, " + "field1MappedField, " + "field2MappedField " + "FROM " + @@ -89,8 +89,8 @@ void testApplyMappingToExistingData() { databaseManager.createArtifacts(new PostgresMappingDefinition("dynamicMappingId", "kogito_data_cache", "json_value", - List.of(new PostgresField("key")), - List.of(new PostgresPartitionField("name", CACHE_NAME)), + List.of(new PostgresField("var_name")), + List.of(new PostgresPartitionField("cache_name", CACHE_NAME)), "DynamicTypeExtract", List.of(new PostgresMapping("field1", new PostgresJsonField("field1MappedField", JsonType.STRING)), @@ -120,8 +120,8 @@ private void assertResultSize(final int expected) { @EntityResult( entityClass = DynamicTypeExtractRow.class, fields = { @FieldResult(name = "id", column = "id"), - @FieldResult(name = "key", column = "key"), - @FieldResult(name = "name", column = "name"), + @FieldResult(name = "key", column = "var_name"), + @FieldResult(name = "name", column = "cache_name"), @FieldResult(name = "field1MappedField", column = "field1MappedField"), @FieldResult(name = "field2MappedField", column = "field2MappedField") }) }) diff --git a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/resources/bootstrap.json b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/resources/bootstrap.json index af545a94c1..6a12a98333 100644 --- a/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/resources/bootstrap.json +++ b/persistence-commons/persistence-commons-reporting-parent/persistence-commons-reporting-postgresql-generic/src/test/resources/bootstrap.json @@ -6,12 +6,12 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName": "key" + "fieldName": "var_name" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldValue": "BasicType" } ], @@ -39,12 +39,12 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName": "key" + "fieldName": "var_name" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldValue": "HierarchicalType" } ], @@ -79,12 +79,12 @@ "sourceTableJsonFieldName": "json_value", "sourceTableIdentityFields": [ { - "fieldName": "key" + "fieldName": "var_name" } ], "sourceTablePartitionFields": [ { - "fieldName": "name", + "fieldName": "cache_name", "fieldValue": "ComplexHierarchicalType" } ],