Revision 2748
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_gen.py | ||
---|---|---|
1 | 1 |
# SQL code generation |
2 | 2 |
|
3 |
import copy |
|
3 | 4 |
import operator |
4 | 5 |
import re |
5 | 6 |
import UserDict |
... | ... | |
198 | 199 |
if isinstance(col, Code): return col |
199 | 200 |
else: return Col(col, table) |
200 | 201 |
|
201 |
def set_default_table(col, table):
|
|
202 |
def with_default_table(col, table):
|
|
202 | 203 |
col = as_Col(col) |
203 |
if not isinstance(col, NamedCol) and col.table == None: col.table = table |
|
204 |
if not isinstance(col, NamedCol) and col.table == None: |
|
205 |
col = copy.copy(col) # don't modify input! |
|
206 |
col.table = table |
|
204 | 207 |
return col |
205 | 208 |
|
206 | 209 |
def set_cols_table(table, cols): |
... | ... | |
391 | 394 |
def as_ValueCond(value, default_table=assume_literal): |
392 | 395 |
if not isinstance(value, ValueCond): |
393 | 396 |
if default_table is not assume_literal: |
394 |
value = set_default_table(value, default_table)
|
|
397 |
value = with_default_table(value, default_table)
|
|
395 | 398 |
return CompareCond(value) |
396 | 399 |
else: return value |
397 | 400 |
|
... | ... | |
438 | 441 |
right = left_table_col |
439 | 442 |
|
440 | 443 |
# Parse left side |
441 |
left = set_default_table(left, left_table)
|
|
444 |
left = with_default_table(left, left_table)
|
|
442 | 445 |
|
443 | 446 |
# Parse special values |
444 | 447 |
left_on_right = Col(left.name, right_table) |
Also available in: Unified diff
sql_gen.py: Renamed set_default_table() to with_default_table() and copy col before modifying it so don't modify input