From 719c7f622b0a12e15e76712555cd00a8bcf1e88f Mon Sep 17 00:00:00 2001 From: Miroslav Stampar Date: Tue, 22 Jan 2013 15:51:06 +0100 Subject: [PATCH] Probable fix for --technique=Q --dbms=Firebird (but also other potential issues with splitting of fields in expressions) --- lib/core/agent.py | 10 +++------- lib/core/common.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/core/agent.py b/lib/core/agent.py index 37863dcd8..2f6ce6238 100644 --- a/lib/core/agent.py +++ b/lib/core/agent.py @@ -17,6 +17,7 @@ from lib.core.common import randomInt from lib.core.common import randomStr from lib.core.common import safeSQLIdentificatorNaming from lib.core.common import singleTimeWarnMessage +from lib.core.common import splitFields from lib.core.common import unArrayizeValue from lib.core.common import zeroDepthSearch from lib.core.data import conf @@ -384,11 +385,7 @@ class Agent(object): if fields.startswith("(CASE") or fields.startswith("(IIF") or fields.startswith("SUBSTR") or fields.startswith("MID(") or re.search(r"\A'[^']+'\Z", fields): nulledCastedConcatFields = fields else: - fields = fields.replace(", ", ',') - commas = [-1, len(fields)] - commas.extend(zeroDepthSearch(fields, ',')) - commas = sorted(commas) - fieldsSplitted = [fields[x + 1:y] for (x, y) in zip(commas, commas[1:])] + fieldsSplitted = splitFields(fields) dbmsDelimiter = queries[Backend.getIdentifiedDbms()].delimiter.query nulledCastedFields = [] @@ -453,8 +450,7 @@ class Agent(object): if re.search("\A\w+\(.*\)", fieldsToCastStr, re.I) or (fieldsSelectCase and "WHEN use" not in query) or fieldsSubstr: fieldsToCastList = [fieldsToCastStr] else: - fieldsToCastList = fieldsToCastStr.replace(", ", ',') - fieldsToCastList = fieldsToCastList.split(',') + fieldsToCastList = splitFields(fieldsToCastStr) return fieldsSelectFrom, fieldsSelect, fieldsNoSelect, fieldsSelectTop, fieldsSelectCase, fieldsToCastList, fieldsToCastStr, fieldsExists diff --git a/lib/core/common.py b/lib/core/common.py index ebc006533..141eda6b4 100644 --- a/lib/core/common.py +++ b/lib/core/common.py @@ -3310,6 +3310,18 @@ def zeroDepthSearch(expression, value): return retVal +def splitFields(fields, delimiter=','): + """ + Returns list of fields splitted by delimiter + """ + + fields = fields.replace("%s " % delimiter, delimiter) + commas = [-1, len(fields)] + commas.extend(zeroDepthSearch(fields, ',')) + commas = sorted(commas) + + return [fields[x + 1:y] for (x, y) in zip(commas, commas[1:])] + def pollProcess(process, suppress_errors=False): while True: dataToStdout(".")