Revision 2615
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
881 | 881 |
return col.table.name.find('(') >= 0 and col.name == 'result' |
882 | 882 |
|
883 | 883 |
def into_table_name(out_table, in_tables0, mapping, is_func): |
884 |
def in_col_str(in_col): |
|
885 |
in_col = sql_gen.remove_col_rename(in_col) |
|
886 |
if isinstance(in_col, sql_gen.Col): |
|
887 |
table = in_col.table |
|
888 |
if table == in_tables0: |
|
889 |
in_col = sql_gen.to_name_only_col(in_col) |
|
890 |
elif is_func_result(in_col): in_col = table # omit col name |
|
891 |
return str(in_col) |
|
892 |
|
|
884 | 893 |
str_ = str(out_table) |
885 | 894 |
if is_func: |
886 |
def col(out_col, in_col): |
|
887 |
# Add out_col |
|
888 |
out_col = sql_gen.to_name_only_col(out_col) |
|
889 |
str_ = '' |
|
890 |
if out_col.name != 'value': str_ += str(out_col)+'=' |
|
891 |
|
|
892 |
# Add in_col |
|
893 |
in_col = sql_gen.remove_col_rename(in_col) |
|
894 |
if isinstance(in_col, sql_gen.Col): |
|
895 |
table = in_col.table |
|
896 |
if table == in_tables0: |
|
897 |
in_col = sql_gen.to_name_only_col(in_col) |
|
898 |
elif is_func_result(in_col): in_col = table # omit col name |
|
899 |
str_ += str(in_col) |
|
900 |
|
|
901 |
return str_ |
|
895 |
str_ += '(' |
|
902 | 896 |
|
903 |
str_ += '('+(', '.join((col(k, v) for k, v in mapping.iteritems())))+')' |
|
897 |
try: value_in_col = mapping['value'] |
|
898 |
except KeyError: |
|
899 |
str_ += ', '.join((k+'='+in_col_str(v) |
|
900 |
for k, v in mapping.iteritems())) |
|
901 |
else: str_ += in_col_str(value_in_col) |
|
902 |
|
|
903 |
str_ += ')' |
|
904 | 904 |
else: str_ += '_pkeys' |
905 | 905 |
return str_ |
906 | 906 |
|
Also available in: Unified diff
sql.py: into_table_name(): If relational function has a value argument, don't include other arguments, to save space