Skip to content
Snippets Groups Projects
Commit 3b440918 authored by Andre Loreth's avatar Andre Loreth
Browse files

Replace all db.translateStatement and db.translateCondition with...

Replace all db.translateStatement and db.translateCondition with SqlUtils.translateStatementWithQuotes and SqlUtil.translateConditionWithQuotes
parent a9b152db
No related branches found
No related tags found
No related merge requests found
Showing
with 25 additions and 22 deletions
......@@ -23,7 +23,7 @@ if (vars.exists("$param.RowId_param") && vars.get("$param.RowId_param") && vars.
.andPrepareVars("ACTIVITYLINK.OBJECT_TYPE", "$param.ObjectId_param");
// TODO: more performant way than IN. Maybe a join??
cond.and(db.translateStatement(activityLinkCond.buildSql("ACTIVITY.ACTIVITYID in (select ACTIVITYLINK.ACTIVITY_ID from ACTIVITYLINK", "1=2", ")")))
cond.and(SqlUtils.translateStatementWithQuotes(activityLinkCond.buildSql("ACTIVITY.ACTIVITYID in (select ACTIVITYLINK.ACTIVITY_ID from ACTIVITYLINK", "1=2", ")")))
}
if(vars.getString("$param.OnlyInnate_param") == "true")
......
......@@ -21,5 +21,5 @@ if (usageFilter)
from AB_KEYWORD_ATTRIBUTERELATION ", null, ")"));
}
cond = db.translateStatement(cond.build("1 = 2"));
cond = SqlUtils.translateStatementWithQuotes(cond.build("1 = 2"));
result.string(cond);
\ No newline at end of file
......@@ -8,7 +8,7 @@ if (vars.exists("$local.idvalue")) {
affectedIds = vars.get("$local.idvalue");
}
result.string(db.translateStatement(SqlCondition.begin()
result.string(SqlUtils.translateStatementWithQuotes(SqlCondition.begin()
.andIn("ADDRESS.ADDRESSID", affectedIds)
.buildSql("select \n\
ADDRESS.ADDRESSID as \"_uid_\", \n\
......
import("Sql_lib");
import("KeywordRegistry_basic");
import("Contact_lib");
import("system.db");
import("system.result");
var commRestrictionCond = ContactUtils.getCommRestrictionCondition($KeywordRegistry.communicationMediumCampaign$mail()).build();
var sql = "case when (" + db.translateStatement(commRestrictionCond) + ") then 'true' else 'false' end";
var sql = "case when (" + SqlUtils.translateStatementWithQuotes(commRestrictionCond) + ") then 'true' else 'false' end";
result.string(sql);
import("Sql_lib");
import("Contact_lib");
import("system.translate");
import("system.db");
......@@ -8,7 +9,7 @@ import("KeywordRegistry_basic");
var commRestrictionCond = ContactUtils.getCommRestrictionCondition($KeywordRegistry.communicationMediumCampaign$mail()).build();
var keywordSql = KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.bulkMailRecipientStatus(), "BULKMAILRECIPIENT.STATUS");
var sql = "case when (" + db.translateStatement(commRestrictionCond)
var sql = "case when (" + SqlUtils.translateStatementWithQuotes(commRestrictionCond)
+ ") then '" + translate.text("Advertising ban")
+ "' else (" + keywordSql + ") end";
result.string(sql);
......@@ -15,4 +15,4 @@ else
if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW)
cond.andPrepareVars("CAMPAIGNCOST.CAMPAIGNCOSTID", "$field.CAMPAIGNCOSTID", "# <> ?");
result.string(db.translateStatement(cond.buildSql("select CATEGORY from CAMPAIGNCOST", "1=2", "group by CATEGORY")));
\ No newline at end of file
result.string(SqlUtils.translateStatementWithQuotes(cond.buildSql("select CATEGORY from CAMPAIGNCOST", "1=2", "group by CATEGORY")));
\ No newline at end of file
......@@ -11,7 +11,7 @@ if (1 < db.cell(SqlCondition.begin()
.andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", vars.get("$field.CLASSIFICATIONTYPE"))
.buildSql("select count(*) from CLASSIFICATIONTYPE", "1=2")))
{
db.deleteData("CLASSIFICATION", "CLASSIFICATION.CLASSIFICATIONTYPE_ID in (" + db.translateStatement(
db.deleteData("CLASSIFICATION", "CLASSIFICATION.CLASSIFICATIONTYPE_ID in (" + SqlUtils.translateStatementWithQuotes(
SqlCondition.begin()
.andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID", classificationTypeId)
.buildSql("select CLASSIFICATIONTYPE.CLASSIFICATIONTYPEID from CLASSIFICATIONTYPE", "1=2")) + ")");
......
......@@ -20,5 +20,5 @@ if (usageFilter)
from AB_KEYWORD_ATTRIBUTERELATION ", null, ")"));
}
cond = db.translateStatement(cond.build("1 = 2"));
cond = SqlUtils.translateStatementWithQuotes(cond.build("1 = 2"));
result.string(cond);
\ No newline at end of file
......@@ -7,4 +7,4 @@ var cond = SqlCondition.begin()
.andPrepareVars("DOCUMENTTEMPLATE.KIND", "$param.DocumentTemplateType_param")
.andPrepareVars("DOCUMENTTEMPLATE.CLASSIFICATION", "$param.DocumentTemplateTypeClassification_param");
result.string(db.translateStatement(cond.build("1=1")));
\ No newline at end of file
result.string(SqlUtils.translateStatementWithQuotes(cond.build("1=1")));
\ No newline at end of file
import("Sql_lib");
import("KeywordRegistry_basic");
import("Contact_lib");
import("system.db");
import("system.result");
var commRestrictionCond = ContactUtils.getCommRestrictionCondition($KeywordRegistry.communicationMediumCampaign$letter()).build();
var sql = "case when (" + db.translateStatement(commRestrictionCond) + ") then 'true' else 'false' end";
var sql = "case when (" + SqlUtils.translateStatementWithQuotes(commRestrictionCond) + ") then 'true' else 'false' end";
result.string(sql);
......@@ -6,13 +6,13 @@ import("ObjectRelation_lib");
var relationTypeData = ObjectRelationUtils.getRelationType(vars.get("$field.OBJECTRELATIONTYPEID"));
var sql1 = db.translateStatement(SqlCondition.begin()
var sql1 = SqlUtils.translateStatementWithQuotes(SqlCondition.begin()
.andPrepareVars("AB_OBJECTRELATION.OBJECT1_ROWID", "$field.PARENT_ID")
.andPrepare("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", relationTypeData[7])
.andPrepare("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", relationTypeData[8])
.buildSql("select OBJECT2_ROWID from AB_OBJECTRELATION", "1=2"));
var sql2 = db.translateStatement(SqlCondition.begin()
var sql2 = SqlUtils.translateStatementWithQuotes(SqlCondition.begin()
.andPrepareVars("AB_OBJECTRELATION.OBJECT2_ROWID", "$field.PARENT_ID")
.andPrepare("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE1", relationTypeData[7])
.andPrepare("AB_OBJECTRELATION.AB_OBJECTRELATIONTYPE2", relationTypeData[8])
......
......@@ -19,7 +19,7 @@ if(pid != "")
//TODO: loading from db until loading from Consumer is possible.
var ProductDetails = ProductUtils.getProductDetails(pid, PriceListFilter,
[["info", db.translateStatement(SqlCondition.begin()
[["info", SqlUtils.translateStatementWithQuotes(SqlCondition.begin()
.andPrepareVars("DESCRIPTIONTRANSLATION.OBJECT_ROWID", "local.value")
.and("DESCRIPTIONTRANSLATION.OBJECT_TYPE = 'Product'")
.andPrepareVars("DESCRIPTIONTRANSLATION.LANG", "$param.Language_param")
......
......@@ -26,7 +26,7 @@ if (vars.exists("$param.RowId_param") && vars.get("$param.RowId_param") && vars.
.andPrepareVars("TASKLINK.OBJECT_TYPE", "$param.ObjectId_param");
// TODO: more performant way than IN. Maybe a join?
cond.and(db.translateStatement(taskLinkCond.buildSql("TASK.TASKID in (select TASKLINK.TASK_ID from TASKLINK", "1=2", ")")))
cond.and(SqlUtils.translateStatementWithQuotes(taskLinkCond.buildSql("TASK.TASKID in (select TASKLINK.TASK_ID from TASKLINK", "1=2", ")")))
}
if (loadNothing)
......
......@@ -24,7 +24,7 @@ if (vars.exists("$param.RowId_param") && vars.get("$param.RowId_param") && vars.
.andPrepareVars("TASKLINK.OBJECT_TYPE", "$param.ObjectId_param");
// TODO: more performant way than IN. Maybe a join?
cond.and(db.translateStatement(activityLinkCond.buildSql("TASK.TASKID in (select TASKLINK.TASK_ID from TASKLINK", "1=2", ")")))
cond.and(SqlUtils.translateStatementWithQuotes(activityLinkCond.buildSql("TASK.TASKID in (select TASKLINK.TASK_ID from TASKLINK", "1=2", ")")))
}
if (loadNothing)
......
......@@ -139,7 +139,7 @@ AttributeFilterExtensionMaker.getFilterCondition = function(pObjectType, pFilter
and AB_ATTRIBUTERELATION.AB_ATTRIBUTE_ID = ?) \n\
where " + condition + " )";
}
resSql = db.translateCondition([resSql, preparedValues]);
resSql = SqlUtils.translateConditionWithQuotes([resSql, preparedValues]);
return resSql;
};
......
......@@ -423,7 +423,7 @@ CampaignUtils.copyCampaignSteps = function(pSourceCampaignId, pTargetCampaignId)
{
var InputMapping = {
"CAMPAIGNSTEP": {
condition: db.translateCondition(SqlCondition().begin()
condition: SqlUtils.translateConditionWithQuotes(SqlCondition().begin()
.andPrepare("CAMPAIGN.CAMPAIGN_ID", pSourceCampaignId)
.buildSql("", "1=2", "order by SORTING", false)),
ValueMapping: {
......
......@@ -26,7 +26,7 @@ ClassificationUtils.getScore = function(pClassificationType, pObjectType, pObjec
.andPrepare("CLASSIFICATIONTYPE.CLASSIFICATIONTYPE", pClassificationType)
.andPrepareIfSet("CLASSIFICATIONTYPE.CLASSIFICATIONGROUP", pClassificationGroup)
.buildSql("select CLASSIFICATIONTYPE.CLASSIFICATIONGROUP, case when sum(score) is not null then sum(score) else 0 end from CLASSIFICATIONTYPE "
+ db.translateStatement(SqlCondition.begin()
+ SqlUtils.translateStatementWithQuotes(SqlCondition.begin()
.andPrepare("CLASSIFICATION.OBJECT_TYPE", pObjectType)
.andPrepare("CLASSIFICATION.OBJECT_ROWID", pObjectRowid)
.buildSql("left join CLASSIFICATION on CLASSIFICATIONTYPEID = CLASSIFICATIONTYPE_ID and", "1=2", "", false))
......
......@@ -140,7 +140,7 @@ CommUtil.getStandardSubSqlForCategory = function(pCategory, pContactField)
cond.and("COMMUNICATION.ISSTANDARD = 1");
var res = db.translateStatement(cond.buildSql("select max(COMMUNICATION.ADDR) from COMMUNICATION", "1=0"));
var res = SqlUtils.translateStatementWithQuotes(cond.buildSql("select max(COMMUNICATION.ADDR) from COMMUNICATION", "1=0"));
return res;
};
......
......@@ -47,5 +47,5 @@ CountryUtils.getResolvedNameFromIso2Sql = function(pDbFieldName, pLocale)
{
var countryData = CountryInfoData.getIso2NameData();
var resSql = SqlUtils.getResolvingCaseWhen(countryData, pDbFieldName, pLocale);
return db.translateStatement(resSql);
return SqlUtils.translateStatementWithQuotes(resSql);
};
\ No newline at end of file
......@@ -27,7 +27,7 @@ KeywordUtils.getResolvedTitleSqlPart = function(pContainerName, pDbFieldName, pL
{
var keywordData = KeywordData.getSimpleData(pContainerName, pLocale);
var resSql = SqlUtils.getResolvingCaseWhen(keywordData, pDbFieldName, pLocale);
return db.translateStatement(resSql);
return SqlUtils.translateStatementWithQuotes(resSql);
};
/**
......@@ -305,7 +305,7 @@ LanguageKeywordUtils.getResolvedTitleSqlPart = function(pDbFieldName, pLocale)
{
var data = LanguageData.getData();
var resSql = SqlUtils.getResolvingCaseWhen(data, pDbFieldName, pLocale);
return db.translateStatement(resSql);
return SqlUtils.translateStatementWithQuotes(resSql);
};
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment