Project

General

Profile

« Previous | Next » 

Revision 2659

sql_gen.py: Added as_Code(). Split SQL code objects into separate sections so unparameterized classes would be separate from general classes.

View differences:

lib/sql_gen.py
37 37

  
38 38
def clean_name(name): return name.replace('"', '').replace('`', '')
39 39

  
40
##### SQL code objects
40
##### General SQL code objects
41 41

  
42 42
class MockDb:
43 43
    def esc_value(self, value): return strings.repr_no_u(value)
......
50 50
    
51 51
    def __str__(self): return clean_name(strings.repr_no_u(self))
52 52

  
53
##### Unparameterized code objects
54

  
53 55
class Code(BasicObject):
54 56
    def to_str(self, db): raise NotImplementedError()
55 57
    
......
60 62
    
61 63
    def to_str(self, db): return self.str_
62 64

  
65
def as_Code(value):
66
    if util.is_str(value): return CustomCode(value)
67
    else: return Literal(value)
68

  
63 69
class Expr(Code):
64 70
    def __init__(self, expr): self.expr = expr
65 71
    

Also available in: Unified diff