Revision 2499
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql_gen.py | ||
---|---|---|
6 | 6 |
import strings |
7 | 7 |
import util |
8 | 8 |
|
9 |
##### Escaping |
|
10 |
|
|
11 |
def esc_name(name, quote='"'): |
|
12 |
return quote + name.replace(quote, quote+quote) + quote |
|
13 |
# doubling an embedded quote escapes it in both PostgreSQL and MySQL |
|
14 |
|
|
9 | 15 |
##### SQL code objects |
10 | 16 |
|
11 | 17 |
class MockDb: |
12 | 18 |
def esc_value(self, value): return repr(value) |
13 | 19 |
|
14 |
def esc_name(self, name): return '"'+name+'"'
|
|
20 |
def esc_name(self, name): return esc_name(name)
|
|
15 | 21 |
mockDb = MockDb() |
16 | 22 |
|
17 | 23 |
class Code(objects.BasicObject): |
Also available in: Unified diff
sql_gen.py: Added esc_name() and use it in MockDb.esc_name()