Skip to content

Commit

Permalink
Merge pull request #169 from darikg/double_precision
Browse files Browse the repository at this point in the history
(postgresql) Add "double precision" as a built-in datatype
  • Loading branch information
andialbrecht committed Feb 8, 2015
2 parents 161d0ae + 313f0f3 commit 9cbba89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions sqlparse/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class Lexer(object):
(r'END(\s+IF|\s+LOOP)?\b', tokens.Keyword),
(r'NOT NULL\b', tokens.Keyword),
(r'CREATE(\s+OR\s+REPLACE)?\b', tokens.Keyword.DDL),
(r'DOUBLE\s+PRECISION\b', tokens.Name.Builtin),
(r'(?<=\.)[^\W\d_]\w*', tokens.Name),
(r'[^\W\d_]\w*', is_keyword),
(r'[;:()\[\],\.]', tokens.Punctuation),
Expand Down
9 changes: 9 additions & 0 deletions tests/test_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ def test_psql_quotation_marks(): # issue83
assert len(t) == 2


def test_double_precision_is_builtin():
sql = 'DOUBLE PRECISION'
t = sqlparse.parse(sql)[0].tokens
assert (len(t) == 1
and t[0].ttype == sqlparse.tokens.Name.Builtin
and t[0].value == 'DOUBLE PRECISION')


@pytest.mark.parametrize('ph', ['?', ':1', ':foo', '%s', '%(foo)s'])
def test_placeholder(ph):
p = sqlparse.parse(ph)[0].tokens
Expand Down Expand Up @@ -196,3 +204,4 @@ def test_single_quotes_with_linebreaks(): # issue118
p = sqlparse.parse("'f\nf'")[0].tokens
assert len(p) == 1
assert p[0].ttype is T.String.Single

0 comments on commit 9cbba89

Please sign in to comment.