Пример #1
0
def findStringOrderbyAttributes(queryobj):
    orderbyAttr = ""
    if(queryobj is not None):
        orderbyIdent = queryobj.getOrderbyIdent()
        if (orderbyIdent is  not None):
            for oid in orderbyIdent:
#                print oid
                if (myhelper.isAggregate(oid)):
#                    print"agg"
                    orderbyAttr+= str(oid)
                elif (myhelper.isOrderbyOperator(oid)):
#                    print "ops"
                    orderbyAttr = orderbyAttr.strip(", ")
                    orderbyAttr+= " " + myhelper.remAggregate(str(oid)) + ", "
                elif(myhelper.isMathOperator(str(oid))):
#                    print "myops %s" %oid
                    orderbyAttr+=str(oid)
                else:
#                    print "else"
                    orderbyAttr+= str(oid) + ", "
    
        orderbyAttr = orderbyAttr.strip("_")
        orderbyAttr = orderbyAttr.strip(", ")
    
#    print "orderbyAttr: %s" %orderbyAttr
    return orderbyAttr
Пример #2
0
def findIdentifierListWithKeywords(token,mytoklist):
#    print "I got into findidentifierListWIthKeywords: %s" %token
    foundAttr = False
    curr = token
    foundAggregate = False
#    print "TOken: %s" %token
    if (curr.ttype is None):
        if ("," in str(curr)):
            #After an aggregate is found, the clause is no longer an identifierList.
            commalist = str(curr).split(",")
#            commalist = str(curr).split()
            for  i in commalist:
                i = str(i).strip()
                itemtok = sql.Token(None,i)
                mytoklist.append(itemtok)
#            print commalist
        else:
#        print "Im on the None: %s"%curr
            mytoklist.append(curr)
    elif (curr.ttype is Token.Keyword):
        if (myhelper.isAggregate(curr)):
            mytoklist.append(curr)
            foundAggregate = True
        elif (myhelper.isLogicalOperator(curr)):
            mytoklist.append(curr)
        elif (myhelper.isOrderbyOperator(curr)):
            mytoklist.append(curr)
        else:
            foundAttr = True
    elif (curr.ttype is Token.Punctuation):
        mytoklist.append(curr)
    else:
#        print "Im on the else: %s"%curr
        mytoklist.append(curr)
    return (foundAttr, mytoklist, foundAggregate)