'Take in input a sequence of fields string and return its processed
nulled, casted and concatenated fields string.
Examples:
MySQL input:  user,password
MySQL output: IFNULL(CAST(user AS CHAR(10000)), \' \'),\'UWciUe\',IFNULL(CAST(password AS CHAR(10000)), \' \')
MySQL scope:  SELECT user, password FROM mysql.user
PostgreSQL input:  usename,passwd
PostgreSQL output: COALESCE(CAST(usename AS CHARACTER(10000)), \' \')||\'xRBcZW\'||COALESCE(CAST(passwd AS CHARACTER(10000)), \' \')
PostgreSQL scope:  SELECT usename, passwd FROM pg_shadow
Oracle input:  COLUMN_NAME,DATA_TYPE
Oracle output: NVL(CAST(COLUMN_NAME AS VARCHAR(4000)), \' \')||\'UUlHUa\'||NVL(CAST(DATA_TYPE AS VARCHAR(4000)), \' \')
Oracle scope:  SELECT COLUMN_NAME, DATA_TYPE FROM SYS.ALL_TAB_COLUMNS WHERE TABLE_NAME=\'%s\'
Microsoft SQL Server input:  name,master.dbo.fn_varbintohexstr(password)
Microsoft SQL Server output: ISNULL(CAST(name AS VARCHAR(8000)), \' \')+\'nTBdow\'+ISNULL(CAST(master.dbo.fn_varbintohexstr(password) AS VARCHAR(8000)), \' \')
Microsoft SQL Server scope:  SELECT name, master.dbo.fn_varbintohexstr(password) FROM master..sysxlogins
@param fields: fields string to be processed
@type fields: C{str}
@return: fields string nulled, casted and concatened
@rtype: C{str}'

def nullCastConcatFields(self, fields):

    if (not Backend.getDbms()):
        return fields
    if (fields.startswith('(CASE') or fields.startswith('(IIF') or fields.startswith('SUBSTR') or fields.startswith('MID(') or re.search("\\A'[^']+'\\Z", fields)):
        nulledCastedConcatFields = fields
    else:
        fieldsSplitted = splitFields(fields)
        dbmsDelimiter = queries[Backend.getIdentifiedDbms()].delimiter.query
        nulledCastedFields = []
        for field in fieldsSplitted:
            nulledCastedFields.append(self.nullAndCastField(field))
        delimiterStr = ("%s'%s'%s" % (dbmsDelimiter, kb.chars.delimiter, dbmsDelimiter))
        nulledCastedConcatFields = delimiterStr.join((field for field in nulledCastedFields))
    return nulledCastedConcatFields
