Project

General

Profile

« Previous | Next » 

Revision 2592

sql.py: into_table_name(): In function args, keep the input table name for input columns to identify where they came from, except for the main input table name because it makes the string too long

View differences:

sql.py
872 872
        if not create: raise
873 873
        return put(db, table, row, pkey, row_ct_ref) # insert new row
874 874

  
875
def into_table_name(out_table, mapping, is_func):
875
def into_table_name(out_table, in_tables0, mapping, is_func):
876 876
    str_ = str(out_table)
877 877
    if is_func:
878
        def is_in_table_col(col):
879
            return isinstance(col, sql_gen.Col) and col.table == in_tables0
878 880
        def col(out_col, in_col):
879 881
            # Add out_col
880 882
            out_col = sql_gen.to_name_only_col(out_col)
......
882 884
            if out_col.name != 'value': str_ += str(out_col)+'='
883 885
            
884 886
            # Add in_col
885
            in_col = sql_gen.to_name_only_col(sql_gen.remove_col_rename(in_col))
887
            in_col = sql_gen.remove_col_rename(in_col)
888
            if is_in_table_col(in_col):
889
                in_col = sql_gen.to_name_only_col(in_col)
886 890
            str_ += str(in_col)
887 891
            
888 892
            return str_
......
909 913
    '''
910 914
    out_table = sql_gen.as_Table(out_table)
911 915
    mapping = sql_gen.ColDict(mapping)
912
    if into == None: into = into_table_name(out_table, mapping, is_func)
913
    into = sql_gen.as_Table(into)
914 916
    
915 917
    def log_debug(msg): db.log_debug(msg, level=1.5)
916 918
    def col_ustr(str_):
......
928 930
    input_joins = [in_tables0]+[sql_gen.Join(v,
929 931
        {in_pkey: sql_gen.join_same_not_null}) for v in in_tables_]
930 932
    
933
    if into == None:
934
        into = into_table_name(out_table, in_tables0, mapping, is_func)
935
    into = sql_gen.as_Table(into)
936
    
931 937
    log_debug('Joining together input tables into temp table')
932 938
    # Place in new table for speed and so don't modify input if values edited
933 939
    in_table = sql_gen.Table('in')

Also available in: Unified diff