Revision 2703
Added by Aaron Marcuse-Kubitza over 12 years ago
sql_gen.py | ||
---|---|---|
204 | 204 |
if isinstance(col, NamedCol): col = col.code |
205 | 205 |
return col |
206 | 206 |
|
207 |
def wrap(wrap_func, value): |
|
208 |
'''Wraps a value, propagating any column renaming to the returned value.''' |
|
209 |
if isinstance(value, NamedCol): |
|
210 |
return NamedCol(value.name, wrap_func(value.code)) |
|
211 |
else: return wrap_func(value) |
|
212 |
|
|
207 | 213 |
class ColDict(dicts.DictProxy): |
208 | 214 |
'''A dict that automatically makes inserted entries Col objects''' |
209 | 215 |
|
... | ... | |
258 | 264 |
'''Wraps a value inside a function call. |
259 | 265 |
Propagates any column renaming to the returned value. |
260 | 266 |
''' |
261 |
name = None |
|
262 |
if isinstance(value, NamedCol): name = value.name |
|
263 |
value = FunctionCall(function, value) |
|
264 |
if name != None: value = NamedCol(name, value) |
|
265 |
return value |
|
267 |
return wrap(lambda v: FunctionCall(function, v), value) |
|
266 | 268 |
|
267 | 269 |
def unwrap_func_call(func_call, check_name=None): |
268 | 270 |
'''Unwraps any function call to its first argument. |
Also available in: Unified diff
sql_gen.py: Added wrap() and use it in wrap_in_func()