Esempio n. 1
0
def p_op_unique(t):
    '''op_unique : PAR_ABRE list_id PAR_CIERRA
                 | constraint CHECK PAR_ABRE  expression PAR_CIERRA
                 | '''
    try:
        if t[1] == '(':
            t[0] = t[2]
        else:
            t[0] = check_simple(t[1], None, t.lineno, t.lexpos, num_nodo)
            num_nodo += 6
    except:
        t[0] = None
Esempio n. 2
0
def p_condition_column(t):
    '''condition_column : constraint UNIQUE PAR_ABRE list_id PAR_CIERRA
                        | constraint CHECK PAR_ABRE expression PAR_CIERRA
                        | constraint key_table'''
    global num_nodo
    if isinstance(t[2], P_Key) or isinstance(t[2], F_key):
        t[2].constraint = t[1]
        t[0] = t[2]
    elif t[2].lower() == 'unique':
        t[0] = unique_simple(t[1], t[4], t.lineno(1), t.lexpos(1), num_nodo)
        num_nodo += 4 + len(t[4])
    elif t[2].lower() == 'check':
        t[0] = check_simple(t[1], t[4], t.lineno(1), t.lexpos(1), num_nodo)
        num_nodo += 6
Esempio n. 3
0
def p_condition_column(t):
    '''condition_column :  constraint UNIQUE op_unique
                         | constraint CHECK PAR_ABRE expression PAR_CIERRA
                         | key_table'''
    global num_nodo
    try:
        if t[2].lower() == 'unique':
            t[0] = unique_simple(t[1], t[3], t.lineno, t.lexpos, num_nodo)
            num_nodo += 4
        elif t[2].lower() == 'check':
            t[0] = check_simple(t[1], None, t.lineno, t.lexpos, num_nodo)
            num_nodo += 6

    except:

        t[0] = t[1]
Esempio n. 4
0
def p_aux_condition_column(t):
    '''condition_column : DEFAULT expression
                        | NOT NULL
                        | UNIQUE PAR_ABRE list_id PAR_CIERRA
                        | CHECK PAR_ABRE expression PAR_CIERRA
 		                | '''
    global num_nodo
    try:
        if t[1].lower() == 'default':
            t[0] = condicion_simple(t[1], t[2], t.lineno(1), t.lexpos(1), num_nodo)
            num_nodo += 3
        elif t[1].lower() == 'not':
            t[0] = condicion_simple(t[1], None, t.lineno(1), t.lexpos(1), num_nodo)
            num_nodo += 3
        elif t[1].lower() == 'unique':
            t[0] = unique_simple(None, t[3], t.lineno(1), t.lexpos(1), num_nodo)
            num_nodo += 4 + len(t[3])
        elif t[1].lower() == 'check':
            t[0] = check_simple(None, t[3], t.lineno(1), t.lexpos(1), num_nodo)
            num_nodo += 6
    except:
        t[0] = None