From 27a6c0d53c2c218030aff1e24b02219cfc13ebd5 Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Mon, 8 Jul 2024 14:34:00 -0500 Subject: [PATCH] CE-1406 in ensureRecordSecurityLockIsRepresented, getTable using table name, not a (potential) alias; avoid NPE on exposedJoins; whitespace; add cloneable in JoinOn --- .../actions/tables/query/JoinsContext.java | 9 +++++---- .../core/model/metadata/joins/JoinOn.java | 20 ++++++++++++++++++- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/actions/tables/query/JoinsContext.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/actions/tables/query/JoinsContext.java index 26767cce..7f2adde6 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/actions/tables/query/JoinsContext.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/actions/tables/query/JoinsContext.java @@ -378,7 +378,7 @@ public class JoinsContext { securityFieldTableAlias = matchedQueryJoin.getJoinTableOrItsAlias(); } - tmpTable = instance.getTable(securityFieldTableAlias); + tmpTable = instance.getTable(aliasToTableNameMap.getOrDefault(securityFieldTableAlias, securityFieldTableAlias)); //////////////////////////////////////////////////////////////////////////////////////// // set the baseTableOrAlias for the next iteration to be this join's joinTableOrAlias // @@ -466,8 +466,8 @@ public class JoinsContext ////////////////////////////////////////////////////////////////////////////////////////////////////////////// // check if the key type has an all-access key, and if so, if it's set to true for the current user/session // ////////////////////////////////////////////////////////////////////////////////////////////////////////////// - QSecurityKeyType securityKeyType = instance.getSecurityKeyType(recordSecurityLock.getSecurityKeyType()); - boolean haveAllAccessKey = false; + QSecurityKeyType securityKeyType = instance.getSecurityKeyType(recordSecurityLock.getSecurityKeyType()); + boolean haveAllAccessKey = false; if(StringUtils.hasContent(securityKeyType.getAllAccessKeyName())) { ////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1118,7 +1118,7 @@ public class JoinsContext if(useExposedJoins) { QTableMetaData mainTable = QContext.getQInstance().getTable(mainTableName); - for(ExposedJoin exposedJoin : mainTable.getExposedJoins()) + for(ExposedJoin exposedJoin : CollectionUtils.nonNullList(mainTable.getExposedJoins())) { if(exposedJoin.getJoinTable().equals(joinTableName)) { @@ -1159,6 +1159,7 @@ public class JoinsContext } + /******************************************************************************* ** *******************************************************************************/ diff --git a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/joins/JoinOn.java b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/joins/JoinOn.java index 0dc8ed98..78666893 100644 --- a/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/joins/JoinOn.java +++ b/qqq-backend-core/src/main/java/com/kingsrook/qqq/backend/core/model/metadata/joins/JoinOn.java @@ -26,7 +26,7 @@ package com.kingsrook.qqq.backend.core.model.metadata.joins; ** Specification for (at least part of) how two tables join together - e.g., ** leftField = rightField. Used as part of a list in a QJoinMetaData. *******************************************************************************/ -public class JoinOn +public class JoinOn implements Cloneable { private String leftField; private String rightField; @@ -131,4 +131,22 @@ public class JoinOn return (this); } + + + /******************************************************************************* + ** + *******************************************************************************/ + @Override + public JoinOn clone() + { + try + { + JoinOn clone = (JoinOn) super.clone(); + return clone; + } + catch(CloneNotSupportedException e) + { + throw new AssertionError(); + } + } }