diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index 3443fb494ab6846164abe92121fe92a1a702c477..1d8e346e802c2025a59c1fa33471709e84a2eac1 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -1208,6 +1208,11 @@ AttributeUsageUtil.removeDuplicates = function (pAttributeId) * * An AttributeRelationQuery can be used for getting the value and other properties * of an AttributeRelation. You have to instanciate it with "new". + * + * This is built like this because there are several different scenarios for + * loading the values or other properties of one or more attribute relations. Because of this, + * the constructor takes in the common parameters for loading attribute relations and you can + * use methods of the constructed object to configure the query and get the desired result. */ function AttributeRelationQuery (pObjectRowId, pAttributeId, pObjectType) { @@ -1285,10 +1290,11 @@ AttributeRelationQuery.prototype.includeDisplayValue = function () } /** - * @TODO: document object structure - * executes the query and returns the result + * Executes the query and returns the result, depending on the properties of the AttributeRelationQuery object. * - * @return {Object[]} array of objects + * @return {Object[]} Array of objects. By default, the objects contain the properties {attributeId, value, attributeRelationId, attributeName, attributeType}. + * If includeDisplayValue is true, the object also contains the property 'displayValue' and if includeFullAttributeName is true, there is also the property + * 'fullAttributeName'. */ AttributeRelationQuery.prototype.getAttributes = function () { @@ -1373,14 +1379,19 @@ AttributeRelationQuery.prototype.getAttributeCount = function () } /** + * inserts a new attribute relation + * + * @param {String} pValue value of the attribute relation + * @param {boolean} [pOmitValidation=false] if set to true, the current usage of the attribute and max count won't be checked * + * @return {boolean} true, if the attribute relation was inserted, false if the count validation failed */ AttributeRelationQuery.prototype.insertAttribute = function (pValue, pOmitValidation) { - if (this._attributeIds.length !== 1) - throw new Error("AttributeRelationQuery: You have to specify a single attribute id for insert"); if (!this._objectType || !this._rowId) throw new Error("AttributeRelationQuery: Object type and row id are required for insert"); + if (!this._attributeIds || this._attributeIds.length !== 1) + throw new Error("AttributeRelationQuery: You have to specify a single attribute id for insert"); var attributeId = this._attributeIds[0]; diff --git a/process/Permission_lib/process.js b/process/Permission_lib/process.js index 032f1968430fd927d6ab7bd5569f1dbcdfcede81..6c46a946d7ced16430f2dd07466f241bd5e9938a 100644 --- a/process/Permission_lib/process.js +++ b/process/Permission_lib/process.js @@ -594,11 +594,7 @@ function PermissionUtil () {} .or("COND is null") ); } else { - // SqlMaskingUtils.castLob causes an error in this case (at least on derby-db) - // derby-db max size of char is 254 and castLob casts to char first, then to varchar - // size of a condition varies and can be bigger than 254 - // this can cause errors on DBMS with small varchar max size - permissionSelect.and("ASYS_PERMISSION.COND", pCondition, "# as varchar(" + pCondition.length + ") = ?") + permissionSelect.and("ASYS_PERMISSION.COND", pCondition, sqlHelper.cast("#", SQLTYPES.VARCHAR, pCondition.length) + " = ?") } } diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js index 5409e39aa37495a36a7c81905814127fb4ccce90..dae14d849ac2906defcece7a9560f004f40291ab 100644 --- a/process/Sql_lib/process.js +++ b/process/Sql_lib/process.js @@ -2779,7 +2779,10 @@ SqlMaskingUtils.prototype.cast = function(field, targetDatatype, targetLength) { // Because of a Derby bug, you can't cast INTEGER into VARCHAR // Therefor first cast to char then to varchar // https://issues.apache.org/jira/browse/DERBY-2072 - field = "rtrim(" + this.cast(field, SQLTYPES.CHAR, targetLength) + ")"; + // This cast to char is only done if the length is not bigger than 254, + // otherwise the additional cast would result in a different error + if (targetLength <= 254) + field = "rtrim(" + this.cast(field, SQLTYPES.CHAR, targetLength) + ")"; sqlDataType = "varchar"; break; case SQLTYPES.CHAR: