From b12de51a4197cf4f14ad7e3d0f00d6e4b4fd55c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20V=C3=B6gl?= <a.voegl@adito.de> Date: Thu, 10 Dec 2020 07:50:05 +0000 Subject: [PATCH] [Projekt: Entwicklung - xRM][TicketNr.: 1069881][Beleg - Es kann kein neuer Beleg angelegt werden] & add missing Index on new Column --- .../alter_CampaignParticipantResponsibleIndex.xml | 10 ++++++++++ .liquibase/Data_alias/basic/2020.2.2/changelog.xml | 1 + process/Sql_lib/process.js | 13 ++++++++++--- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .liquibase/Data_alias/basic/2020.2.2/alter_CampaignParticipantResponsibleIndex.xml diff --git a/.liquibase/Data_alias/basic/2020.2.2/alter_CampaignParticipantResponsibleIndex.xml b/.liquibase/Data_alias/basic/2020.2.2/alter_CampaignParticipantResponsibleIndex.xml new file mode 100644 index 0000000000..6360542b2d --- /dev/null +++ b/.liquibase/Data_alias/basic/2020.2.2/alter_CampaignParticipantResponsibleIndex.xml @@ -0,0 +1,10 @@ +<?xml version="1.1" encoding="UTF-8" standalone="no"?> +<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd"> + <changeSet author="a.voegl" id="6d545d51-b838-4325-9573-5fe51eade79b"> + <createIndex indexName="IDX_CAMPAIGNPART_RES_CONTACT" tableName="CAMPAIGNPARTICIPANT"> + <column name="RESPONSIBLE_CONTACT_ID"/> + </createIndex> + </changeSet> +</databaseChangeLog> \ No newline at end of file diff --git a/.liquibase/Data_alias/basic/2020.2.2/changelog.xml b/.liquibase/Data_alias/basic/2020.2.2/changelog.xml index 302d930f6b..2a4bea7a4e 100644 --- a/.liquibase/Data_alias/basic/2020.2.2/changelog.xml +++ b/.liquibase/Data_alias/basic/2020.2.2/changelog.xml @@ -6,6 +6,7 @@ <include relativeToChangelogFile="true" file="insert_employeeCountAttribute.xml"/> <include relativeToChangelogFile="true" file="alter_CampaignParticipantResponsible.xml"/> <include relativeToChangelogFile="true" file="alter_TableLeadStatus.xml"/> + <include relativeToChangelogFile="true" file="alter_CampaignParticipantResponsibleIndex.xml"/> <include relativeToChangelogFile="true" file="MSTeams/changelog.xml"/> <include relativeToChangelogFile="true" file="insert_newsletterAttribute.xml"/> <include relativeToChangelogFile="true" file="readd_ExporttemplateIndizes.xml"/> diff --git a/process/Sql_lib/process.js b/process/Sql_lib/process.js index d4d8afdaa4..08f4d90d0b 100644 --- a/process/Sql_lib/process.js +++ b/process/Sql_lib/process.js @@ -4253,10 +4253,11 @@ SqlUtils.getSqlInStatement = function(pFieldname, pData, pQuoteSymbol, pAsPrepar } /** -* resolves key-value pairs (of strings) into a case when expression +* resolves key-value pairs (of strings) into a case when expression; +* This function tries to get the columntype for better type comparison * * @param {String[][]} pKeyValueArray you've to pass a 2D-Array where each element has at pos0 the key and pos1 the value -* @param {String} pDbFieldName name fo the database field where the KEY-value is stored +* @param {String} pDbFieldName name fo the database field where the KEY-value is stored; prefers TABLENAME.COLUMNNAME * @param {String} [pLocale=current client language] specifies the locale for translating the title; can be false if nothing shalle be translated * * @return {String} a SQL-expression (case-when-statement) that resolves the KEYID into the title -> as preparedSatement-elements @@ -4278,7 +4279,13 @@ SqlUtils.getResolvingCaseWhen = function(pKeyValueArray, pDbFieldName, pLocale) }; //!SqlBuilder var resSql = "case ", preparedValues = []; - var colTypeKeyId = SQLTYPES.CHAR; + + var colTypeKeyId = SQLTYPES.CHAR; //the standard type is char + var fields = SqlUtils._parseFieldQualifier(pDbFieldName); //validate the DB-field for proper form (CONTACT.CONTACTID) + if (!(fields instanceof TypeError)) + colTypeKeyId = SqlUtils.getSingleColumnType(pDbFieldName, undefined, this.alias); + //some databases dont auto cast on their own so we need the proper type + var colTypeTitle = SQLTYPES.NVARCHAR; for (var i = 0, l = keyData.length; i < l; i++) { -- GitLab