Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 719c7f6

Browse files
committed
Probable fix for --technique=Q --dbms=Firebird (but also other potential issues with splitting of fields in expressions)
1 parent 2ec828f commit 719c7f6

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

lib/core/agent.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from lib.core.common import randomStr
1818
from lib.core.common import safeSQLIdentificatorNaming
1919
from lib.core.common import singleTimeWarnMessage
20+
from lib.core.common import splitFields
2021
from lib.core.common import unArrayizeValue
2122
from lib.core.common import zeroDepthSearch
2223
from lib.core.data import conf
@@ -384,11 +385,7 @@ def nullCastConcatFields(self, fields):
384385
if fields.startswith("(CASE") or fields.startswith("(IIF") or fields.startswith("SUBSTR") or fields.startswith("MID(") or re.search(r"\A'[^']+'\Z", fields):
385386
nulledCastedConcatFields = fields
386387
else:
387-
fields = fields.replace(", ", ',')
388-
commas = [-1, len(fields)]
389-
commas.extend(zeroDepthSearch(fields, ','))
390-
commas = sorted(commas)
391-
fieldsSplitted = [fields[x + 1:y] for (x, y) in zip(commas, commas[1:])]
388+
fieldsSplitted = splitFields(fields)
392389
dbmsDelimiter = queries[Backend.getIdentifiedDbms()].delimiter.query
393390
nulledCastedFields = []
394391

@@ -453,8 +450,7 @@ def getFields(self, query):
453450
if re.search("\A\w+\(.*\)", fieldsToCastStr, re.I) or (fieldsSelectCase and "WHEN use" not in query) or fieldsSubstr:
454451
fieldsToCastList = [fieldsToCastStr]
455452
else:
456-
fieldsToCastList = fieldsToCastStr.replace(", ", ',')
457-
fieldsToCastList = fieldsToCastList.split(',')
453+
fieldsToCastList = splitFields(fieldsToCastStr)
458454

459455
return fieldsSelectFrom, fieldsSelect, fieldsNoSelect, fieldsSelectTop, fieldsSelectCase, fieldsToCastList, fieldsToCastStr, fieldsExists
460456

lib/core/common.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3310,6 +3310,18 @@ def zeroDepthSearch(expression, value):
33103310

33113311
return retVal
33123312

3313+
def splitFields(fields, delimiter=','):
3314+
"""
3315+
Returns list of fields splitted by delimiter
3316+
"""
3317+
3318+
fields = fields.replace("%s " % delimiter, delimiter)
3319+
commas = [-1, len(fields)]
3320+
commas.extend(zeroDepthSearch(fields, ','))
3321+
commas = sorted(commas)
3322+
3323+
return [fields[x + 1:y] for (x, y) in zip(commas, commas[1:])]
3324+
33133325
def pollProcess(process, suppress_errors=False):
33143326
while True:
33153327
dataToStdout(".")

0 commit comments

Comments
 (0)