escape causing issues with zen
I currently have to use escape='' for every Like, NotLike because our Zen does not do Escape. Adding an escape default in Flavor and removing the default in Like solves this.
Locally fixed with
# __init__.py
class Flavor(object):
'''
Contains the flavor of SQL
Contains:
limitstyle - state the type of pagination
max_limit - limit to use if there is no limit but an offset
paramstyle - state the type of parameter marker formatting
ilike - support ilike extension
no_as - doesn't support AS keyword for column and table
no_boolean - doesn't support boolean type
null_ordering - support NULL ordering
function_mapping - dictionary with Function to replace
filter_ - support filter on aggregate functions
escape_empty - support empty escape
escape_char - default escape character
'''
def __init__(self, limitstyle='limit', max_limit=None, paramstyle='format',
ilike=False, no_as=False, no_boolean=False, null_ordering=True,
function_mapping=None, filter_=False, escape_empty=False, escape_char='\\'):
assert limitstyle in ['fetch', 'limit', 'rownum']
self.limitstyle = limitstyle
self.max_limit = max_limit
self.paramstyle = paramstyle
self.ilike = ilike
self.no_as = no_as
self.no_boolean = no_boolean
self.null_ordering = null_ordering
self.function_mapping = function_mapping or {}
self.filter_ = filter_
self.escape_empty = escape_empty
self.escape_char = escape_char
and
# operators.py
class Like(BinaryOperator):
__slots__ = 'escape'
_operator = 'LIKE'
def __init__(self, left, right, escape=None):
super().__init__(left, right)
print(escape)
assert not escape or len(escape) == 1
self.escape = escape
@property
def params(self):
params = super().params
if self.escape is None:
self.escape = Flavor().get().escape_char
if self.escape or Flavor().get().escape_empty:
params += (self.escape,)
return params
Tried cloning, forking, but it's not nearly as convenient as github. Might try later when I have more time to fiddle with it.