Skip to content

Commit

Permalink
integrated the 'as' support in identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
moskytw committed Oct 13, 2013
1 parent 48898d6 commit 051e986
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mosql/util.py
Expand Up @@ -272,6 +272,9 @@ def value(x):
else:
return str(x)

def _is_pair(x):
return _is_iterable_not_str(x) and len(x) == 2

class OptionError(Exception):
'''The instance of it will be raised when :func:`identifier` detects an
invalid option.
Expand Down Expand Up @@ -321,6 +324,8 @@ def identifier(s):

if _is_select(s):
return paren(s)
elif _is_pair(s):
return '%s AS %s' % (identifier(s[0]), identifier(s[1]))
elif delimit_identifier is None:
return s
elif s.find('.') == -1 and s.find(' ') == -1:
Expand Down Expand Up @@ -348,10 +353,6 @@ def identifier(s):

return r

def as_(a, b):
'''Implement SQL "AS" syntax.'''
return raw('%s AS %s' % (identifier(a), identifier(b)))

@qualifier
def paren(s):
'''A qualifier function which encloses the input with ``()`` (paren).'''
Expand Down

0 comments on commit 051e986

Please sign in to comment.