(self, query)
return fieldsSelectFrom, fieldsSelect, fieldsNoSelect, fieldsSelectTop, fieldsSelectCase, fieldsToCastList, fieldsToCastStr, fieldsExists
Take in input a query string and return its fields (columns) and
        more details.

        Example:

        Input:  SELECT user, password FROM mysql.user
        Output: user,password

        @param query: query to be processed
        @type query: C{str}

        @return: query fields (columns) and more details
        @rtype: C{str}
Take in input a query string and return its fields (columns) and
        more details.
Take in input a query string and return its fields ( columns ) and more details .
def getFields(self, query):
        """
        Take in input a query string and return its fields (columns) and
        more details.

        Example:

        Input:  SELECT user, password FROM mysql.user
        Output: user,password

        @param query: query to be processed
        @type query: C{str}

        @return: query fields (columns) and more details
        @rtype: C{str}
        """

        prefixRegex = r"(?:\s+(?:FIRST|SKIP|LIMIT \d+)\s+\d+)*"
        fieldsSelectTop = re.search(r"\ASELECT\s+TOP\s+[\d]+\s+(.+?)\s+FROM", query, re.I)
        fieldsSelectRownum = re.search(r"\ASELECT\s+([^()]+?),\s*ROWNUM AS LIMIT FROM", query, re.I)
        fieldsSelectDistinct = re.search(r"\ASELECT%s\s+DISTINCT\((.+?)\)\s+FROM" % prefixRegex, query, re.I)
        fieldsSelectCase = re.search(r"\ASELECT%s\s+(\(CASE WHEN\s+.+\s+END\))" % prefixRegex, query, re.I)
        fieldsSelectFrom = re.search(r"\ASELECT%s\s+(.+?)\s+FROM " % prefixRegex, query, re.I)
        fieldsExists = re.search(r"EXISTS\(([^)]*)\)\Z", query, re.I)
        fieldsSelect = re.search(r"\ASELECT%s\s+(.*)" % prefixRegex, query, re.I)
        fieldsSubstr = re.search(r"\A(SUBSTR|MID\()", query, re.I)
        fieldsMinMaxstr = re.search(r"(?:MIN|MAX)\(([^\(\)]+)\)", query, re.I)
        fieldsNoSelect = query

        _ = zeroDepthSearch(query, " FROM ")
        if not _:
            fieldsSelectFrom = None

        if fieldsSubstr:
            fieldsToCastStr = query
        elif fieldsMinMaxstr:
            fieldsToCastStr = fieldsMinMaxstr.groups()[0]
        elif fieldsExists:
            if fieldsSelect:
                fieldsToCastStr = fieldsSelect.groups()[0]
        elif fieldsSelectTop:
            fieldsToCastStr = fieldsSelectTop.groups()[0]
        elif fieldsSelectRownum:
            fieldsToCastStr = fieldsSelectRownum.groups()[0]
        elif fieldsSelectDistinct:
            if Backend.getDbms() in (DBMS.HSQLDB,):
                fieldsToCastStr = fieldsNoSelect
            else:
                fieldsToCastStr = fieldsSelectDistinct.groups()[0]
        elif fieldsSelectCase:
            fieldsToCastStr = fieldsSelectCase.groups()[0]
        elif fieldsSelectFrom:
            fieldsToCastStr = query[:unArrayizeValue(_)] if _ else query
            fieldsToCastStr = re.sub(r"\ASELECT%s\s+" % prefixRegex, "", fieldsToCastStr)
        elif fieldsSelect:
            fieldsToCastStr = fieldsSelect.groups()[0]
        else:
            fieldsToCastStr = fieldsNoSelect

        # Function
        if re.search("\A\w+\(.*\)", fieldsToCastStr, re.I) or (fieldsSelectCase and "WHEN use" not in query) or fieldsSubstr:
            fieldsToCastList = [fieldsToCastStr]
        else:
            fieldsToCastList = splitFields(fieldsToCastStr)

        return fieldsSelectFrom, fieldsSelect, fieldsNoSelect, fieldsSelectTop, fieldsSelectCase, fieldsToCastList, fieldsToCastStr, fieldsExists
def getFields ( self , query ) : prefixRegex = r"(?:\s+(?:FIRST|SKIP|LIMIT \d+)\s+\d+)*" fieldsSelectTop = re . search ( r"\ASELECT\s+TOP\s+[\d]+\s+(.+?)\s+FROM" , query , re . I ) fieldsSelectRownum = re . search ( r"\ASELECT\s+([^()]+?),\s*ROWNUM AS LIMIT FROM" , query , re . I ) fieldsSelectDistinct = re . search ( r"\ASELECT%s\s+DISTINCT\((.+?)\)\s+FROM" % prefixRegex , query , re . I ) fieldsSelectCase = re . search ( r"\ASELECT%s\s+(\(CASE WHEN\s+.+\s+END\))" % prefixRegex , query , re . I ) fieldsSelectFrom = re . search ( r"\ASELECT%s\s+(.+?)\s+FROM " % prefixRegex , query , re . I ) fieldsExists = re . search ( r"EXISTS\(([^)]*)\)\Z" , query , re . I ) fieldsSelect = re . search ( r"\ASELECT%s\s+(.*)" % prefixRegex , query , re . I ) fieldsSubstr = re . search ( r"\A(SUBSTR|MID\()" , query , re . I ) fieldsMinMaxstr = re . search ( r"(?:MIN|MAX)\(([^\(\)]+)\)" , query , re . I ) fieldsNoSelect = query _ = zeroDepthSearch ( query , " FROM " ) if not _ : fieldsSelectFrom = None if fieldsSubstr : fieldsToCastStr = query elif fieldsMinMaxstr : fieldsToCastStr = fieldsMinMaxstr . groups ( ) [ 0 ] elif fieldsExists : if fieldsSelect : fieldsToCastStr = fieldsSelect . groups ( ) [ 0 ] elif fieldsSelectTop : fieldsToCastStr = fieldsSelectTop . groups ( ) [ 0 ] elif fieldsSelectRownum : fieldsToCastStr = fieldsSelectRownum . groups ( ) [ 0 ] elif fieldsSelectDistinct : if Backend . getDbms ( ) in ( DBMS . HSQLDB , ) : fieldsToCastStr = fieldsNoSelect else : fieldsToCastStr = fieldsSelectDistinct . groups ( ) [ 0 ] elif fieldsSelectCase : fieldsToCastStr = fieldsSelectCase . groups ( ) [ 0 ] elif fieldsSelectFrom : fieldsToCastStr = query [ : unArrayizeValue ( _ ) ] if _ else query fieldsToCastStr = re . sub ( r"\ASELECT%s\s+" % prefixRegex , "" , fieldsToCastStr ) elif fieldsSelect : fieldsToCastStr = fieldsSelect . groups ( ) [ 0 ] else : fieldsToCastStr = fieldsNoSelect # Function if re . search ( "\A\w+\(.*\)" , fieldsToCastStr , re . I ) or ( fieldsSelectCase and "WHEN use" not in query ) or fieldsSubstr : fieldsToCastList = [ fieldsToCastStr ] else : fieldsToCastList = splitFields ( fieldsToCastStr ) return fieldsSelectFrom , fieldsSelect , fieldsNoSelect , fieldsSelectTop , fieldsSelectCase , fieldsToCastList , fieldsToCastStr , fieldsExists