Hello community, here is the log from the commit of package python-sqlparse for openSUSE:Factory checked in at 2018-08-24 17:11:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-sqlparse (Old) and /work/SRC/openSUSE:Factory/.python-sqlparse.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-sqlparse" Fri Aug 24 17:11:15 2018 rev:6 rq:631152 version:0.2.4 Changes: -------- --- /work/SRC/openSUSE:Factory/python-sqlparse/python-sqlparse.changes 2017-09-05 15:14:27.227700809 +0200 +++ /work/SRC/openSUSE:Factory/.python-sqlparse.new/python-sqlparse.changes 2018-08-24 17:11:18.250584942 +0200 @@ -1,0 +2,14 @@ +Thu Aug 23 06:31:42 UTC 2018 - [email protected] + +- Update to 0.2.4: + * Add more keywords for MySQL table options (pr328, pr333, by phdru). + * Add more PL/pgSQL keywords (pr357, by Demetrio92). + * Improve parsing of floats (pr330, by atronah). + * Fix parsing of MySQL table names starting with digits (issue337). + * Fix detection of identifiers using comparisons (issue327). + * Fix parsing of UNION ALL after WHERE (issue349). + * Fix handling of semicolon in assignments (issue359, issue358). +- Use fdupes and %license +- Remove shebangs from non-executable python files + +------------------------------------------------------------------- Old: ---- sqlparse-0.2.3.tar.gz New: ---- sqlparse-0.2.4.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-sqlparse.spec ++++++ --- /var/tmp/diff_new_pack.G3x79d/_old 2018-08-24 17:11:21.530588847 +0200 +++ /var/tmp/diff_new_pack.G3x79d/_new 2018-08-24 17:11:21.534588852 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-sqlparse # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-sqlparse -Version: 0.2.3 +Version: 0.2.4 Release: 0 Summary: Non-validating SQL parser License: BSD-3-Clause @@ -26,9 +26,9 @@ Url: https://github.com/andialbrecht/sqlparse Source: https://files.pythonhosted.org/packages/source/s/sqlparse/sqlparse-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{python_module devel} BuildRequires: %{python_module pytest} BuildRequires: %{python_module setuptools} +BuildRequires: fdupes BuildRequires: python-rpm-macros Requires(post): update-alternatives Requires(postun): update-alternatives @@ -42,6 +42,7 @@ %prep %setup -q -n sqlparse-%{version} +sed -i -e '1{\,^#!%{_bindir}/env python,d}' sqlparse/__main__.py sqlparse/cli.py %build %python_build @@ -58,10 +59,12 @@ %check %python_exec %{_bindir}/py.test tests +%python_expand %fdupes %{buildroot}%{$python_sitelib} %files %{python_files} %defattr(-,root,root,-) %doc AUTHORS README.rst +%license LICENSE %python_alternative %{_bindir}/sqlformat %{python_sitelib}/* ++++++ sqlparse-0.2.3.tar.gz -> sqlparse-0.2.4.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/AUTHORS new/sqlparse-0.2.4/AUTHORS --- old/sqlparse-0.2.3/AUTHORS 2017-02-13 13:46:31.000000000 +0100 +++ new/sqlparse-0.2.4/AUTHORS 2017-09-21 10:24:57.000000000 +0200 @@ -11,11 +11,13 @@ * Alexander Beedie <[email protected]> * Alexey Malyshev <[email protected]> * Andrew Tipton <[email protected]> +* atronah <[email protected]> * casey <[email protected]> * Cauê Beloni <[email protected]> * Cristian Orellana <[email protected]> * Dag Wieers <[email protected]> * Darik Gamble <[email protected]> +* Demetrio92 <[email protected]> * Dennis Taylor <[email protected]> * Florian Bauer <[email protected]> * Gavin Wahl <[email protected]> @@ -27,6 +29,7 @@ * Michael Schuller <[email protected]> * Mike Amy <[email protected]> * mulos <[email protected]> +* Oleg Broytman <[email protected]> * Piet Delport <[email protected]> * Prudhvi Vatala <[email protected]> * quest <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/CHANGELOG new/sqlparse-0.2.4/CHANGELOG --- old/sqlparse-0.2.3/CHANGELOG 2017-03-02 05:40:18.000000000 +0100 +++ new/sqlparse-0.2.4/CHANGELOG 2017-09-27 09:08:32.000000000 +0200 @@ -1,3 +1,21 @@ +Release 0.2.4 (Sep 27, 2017) +---------------------------- + +Enhancements + +* Add more keywords for MySQL table options (pr328, pr333, by phdru). +* Add more PL/pgSQL keywords (pr357, by Demetrio92). +* Improve parsing of floats (pr330, by atronah). + +Bug Fixes + +* Fix parsing of MySQL table names starting with digits (issue337). +* Fix detection of identifiers using comparisons (issue327). +* Fix parsing of UNION ALL after WHERE (issue349). +* Fix handling of semicolon in assignments (issue359, issue358). + + + Release 0.2.3 (Mar 02, 2017) ---------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/PKG-INFO new/sqlparse-0.2.4/PKG-INFO --- old/sqlparse-0.2.3/PKG-INFO 2017-03-02 05:48:05.000000000 +0100 +++ new/sqlparse-0.2.4/PKG-INFO 2017-09-27 09:09:24.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: sqlparse -Version: 0.2.3 +Version: 0.2.4 Summary: Non-validating SQL parser Home-page: https://github.com/andialbrecht/sqlparse Author: Andi Albrecht diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/setup.cfg new/sqlparse-0.2.4/setup.cfg --- old/sqlparse-0.2.3/setup.cfg 2017-03-02 05:48:05.000000000 +0100 +++ new/sqlparse-0.2.4/setup.cfg 2017-09-27 09:09:24.000000000 +0200 @@ -1,4 +1,4 @@ -[wheel] +[bdist_wheel] universal = 1 [tool:pytest] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/sqlparse/__init__.py new/sqlparse-0.2.4/sqlparse/__init__.py --- old/sqlparse-0.2.3/sqlparse/__init__.py 2017-03-02 05:41:03.000000000 +0100 +++ new/sqlparse-0.2.4/sqlparse/__init__.py 2017-09-27 09:08:03.000000000 +0200 @@ -17,7 +17,7 @@ from sqlparse.compat import text_type -__version__ = '0.2.3' +__version__ = '0.2.4' __all__ = ['engine', 'filters', 'formatter', 'sql', 'tokens', 'cli'] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/sqlparse/cli.py new/sqlparse-0.2.4/sqlparse/cli.py --- old/sqlparse-0.2.3/sqlparse/cli.py 2017-01-23 12:00:01.000000000 +0100 +++ new/sqlparse-0.2.4/sqlparse/cli.py 2017-09-24 09:02:30.000000000 +0200 @@ -154,14 +154,17 @@ sys.stdin.buffer, encoding=args.encoding).read() else: try: - data = ''.join(open(args.filename, 'r', args.encoding).readlines()) + with open(args.filename, 'r', args.encoding) as f: + data = ''.join(f.readlines()) except IOError as e: return _error( u'Failed to read {0}: {1}'.format(args.filename, e)) + close_stream = False if args.outfile: try: stream = open(args.outfile, 'w', args.encoding) + close_stream = True except IOError as e: return _error(u'Failed to open {0}: {1}'.format(args.outfile, e)) else: @@ -176,4 +179,6 @@ s = sqlparse.format(data, **formatter_opts) stream.write(s) stream.flush() + if close_stream: + stream.close() return 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/sqlparse/engine/grouping.py new/sqlparse-0.2.4/sqlparse/engine/grouping.py --- old/sqlparse-0.2.3/sqlparse/engine/grouping.py 2017-01-23 12:00:01.000000000 +0100 +++ new/sqlparse-0.2.4/sqlparse/engine/grouping.py 2017-09-24 08:49:36.000000000 +0200 @@ -134,7 +134,7 @@ return token.match(T.Assignment, ':=') def valid(token): - return token is not None + return token is not None and token.ttype not in (T.Keyword) def post(tlist, pidx, tidx, nidx): m_semicolon = T.Punctuation, ';' @@ -274,7 +274,7 @@ @recurse() def group_aliased(tlist): I_ALIAS = (sql.Parenthesis, sql.Function, sql.Case, sql.Identifier, - sql.Operation) + sql.Operation, sql.Comparison) tidx, token = tlist.token_next_by(i=I_ALIAS, t=T.Number) while token: @@ -346,10 +346,10 @@ group_order, group_typecasts, group_operator, + group_comparison, group_as, group_aliased, group_assignment, - group_comparison, align_comments, group_identifier_list, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/sqlparse/keywords.py new/sqlparse-0.2.4/sqlparse/keywords.py --- old/sqlparse-0.2.3/sqlparse/keywords.py 2017-02-13 13:45:39.000000000 +0100 +++ new/sqlparse-0.2.4/sqlparse/keywords.py 2017-09-21 10:23:49.000000000 +0200 @@ -14,6 +14,7 @@ val = value.upper() return (KEYWORDS_COMMON.get(val) or KEYWORDS_ORACLE.get(val) or + KEYWORDS_PLPGSQL.get(val) or KEYWORDS.get(val, tokens.Name)), value @@ -35,7 +36,7 @@ (r"`(``|[^`])*`", tokens.Name), (r"´(´´|[^´])*´", tokens.Name), - (r'(\$(?:[_A-Z]\w*)?\$)[\s\S]*?\1', tokens.Literal), + (r'(\$(?:[_A-ZÀ-Ü]\w*)?\$)[\s\S]*?\1', tokens.Literal), (r'\?', tokens.Name.Placeholder), (r'%(\(\w+\))?s', tokens.Name.Placeholder), @@ -47,21 +48,20 @@ # is never a functino, see issue183 (r'(CASE|IN|VALUES|USING)\b', tokens.Keyword), - (r'(@|##|#)[A-Z]\w+', tokens.Name), + (r'(@|##|#)[A-ZÀ-Ü]\w+', tokens.Name), # see issue #39 # Spaces around period `schema . name` are valid identifier # TODO: Spaces before period not implemented - (r'[A-Z]\w*(?=\s*\.)', tokens.Name), # 'Name' . - (r'(?<=\.)[A-Z]\w*', tokens.Name), # .'Name' - (r'[A-Z]\w*(?=\()', tokens.Name), # side effect: change kw to func - - # TODO: `1.` and `.1` are valid numbers + (r'[A-ZÀ-Ü]\w*(?=\s*\.)', tokens.Name), # 'Name' . + # FIXME(atronah): never match, + # because `re.match` doesn't work with lookbehind regexp feature + (r'(?<=\.)[A-ZÀ-Ü]\w*', tokens.Name), # .'Name' + (r'[A-ZÀ-Ü]\w*(?=\()', tokens.Name), # side effect: change kw to func (r'-?0x[\dA-F]+', tokens.Number.Hexadecimal), (r'-?\d*(\.\d+)?E-?\d+', tokens.Number.Float), - (r'-?\d*\.\d+', tokens.Number.Float), - (r'-?\d+', tokens.Number.Integer), - + (r'-?(\d+(\.\d*)|\.\d+)', tokens.Number.Float), + (r'-?\d+(?![_A-ZÀ-Ü])', tokens.Number.Integer), (r"'(''|\\\\|\\'|[^'])*'", tokens.String.Single), # not a real string literal in ANSI SQL: (r'(""|".*?[^\\]")', tokens.String.Symbol), @@ -77,7 +77,7 @@ (r'CREATE(\s+OR\s+REPLACE)?\b', tokens.Keyword.DDL), (r'DOUBLE\s+PRECISION\b', tokens.Name.Builtin), - (r'[_A-Z][_$#\w]*', is_keyword), + (r'[0-9_A-ZÀ-Ü][_$#\w]*', is_keyword), (r'[;:()\[\],\.]', tokens.Punctuation), (r'[<>=~!]+', tokens.Operator.Comparison), @@ -114,6 +114,7 @@ 'ATOMIC': tokens.Keyword, 'AUDIT': tokens.Keyword, 'AUTHORIZATION': tokens.Keyword, + 'AUTO_INCREMENT': tokens.Keyword, 'AVG': tokens.Keyword, 'BACKWARD': tokens.Keyword, @@ -142,6 +143,7 @@ 'CHARACTER_SET_NAME': tokens.Keyword, 'CHARACTER_SET_SCHEMA': tokens.Keyword, 'CHAR_LENGTH': tokens.Keyword, + 'CHARSET': tokens.Keyword, 'CHECK': tokens.Keyword, 'CHECKED': tokens.Keyword, 'CHECKPOINT': tokens.Keyword, @@ -238,6 +240,7 @@ 'ENCODING': tokens.Keyword, 'ENCRYPTED': tokens.Keyword, 'END-EXEC': tokens.Keyword, + 'ENGINE': tokens.Keyword, 'EQUALS': tokens.Keyword, 'ESCAPE': tokens.Keyword, 'EVERY': tokens.Keyword, @@ -636,7 +639,7 @@ 'SERIAL8': tokens.Name.Builtin, 'SIGNED': tokens.Name.Builtin, 'SMALLINT': tokens.Name.Builtin, - 'SYSDATE': tokens.Name.Builtin, + 'SYSDATE': tokens.Name, 'TEXT': tokens.Name.Builtin, 'TINYINT': tokens.Name.Builtin, 'UNSIGNED': tokens.Name.Builtin, @@ -795,4 +798,20 @@ 'TRIGGERS': tokens.Keyword, 'UNLIMITED': tokens.Keyword, + 'UNLOCK': tokens.Keyword, +} + +# PostgreSQL Syntax +KEYWORDS_PLPGSQL = { + 'PARTITION': tokens.Keyword, + 'OVER': tokens.Keyword, + 'PERFORM': tokens.Keyword, + 'NOTICE': tokens.Keyword, + 'PLPGSQL': tokens.Keyword, + 'INHERIT': tokens.Keyword, + 'INDEXES': tokens.Keyword, + + 'FOR': tokens.Keyword, + 'IN': tokens.Keyword, + 'LOOP': tokens.Keyword, } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/sqlparse/sql.py new/sqlparse-0.2.4/sqlparse/sql.py --- old/sqlparse-0.2.3/sqlparse/sql.py 2017-03-02 05:36:14.000000000 +0100 +++ new/sqlparse-0.2.4/sqlparse/sql.py 2017-09-24 08:35:14.000000000 +0200 @@ -526,8 +526,9 @@ class Where(TokenList): """A WHERE clause.""" M_OPEN = T.Keyword, 'WHERE' - M_CLOSE = T.Keyword, ('ORDER', 'GROUP', 'LIMIT', 'UNION', 'EXCEPT', - 'HAVING', 'RETURNING', 'INTO') + M_CLOSE = T.Keyword, ( + 'ORDER', 'GROUP', 'LIMIT', 'UNION', 'UNION ALL', 'EXCEPT', + 'HAVING', 'RETURNING', 'INTO') class Case(TokenList): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/sqlparse/utils.py new/sqlparse-0.2.4/sqlparse/utils.py --- old/sqlparse-0.2.3/sqlparse/utils.py 2017-01-23 12:00:01.000000000 +0100 +++ new/sqlparse-0.2.4/sqlparse/utils.py 2017-05-25 07:55:55.000000000 +0200 @@ -95,9 +95,9 @@ return False elif clss and isinstance(token, clss): return True - elif mpatterns and any((token.match(*pattern) for pattern in mpatterns)): + elif mpatterns and any(token.match(*pattern) for pattern in mpatterns): return True - elif types and any([token.ttype in ttype for ttype in types]): + elif types and any(token.ttype in ttype for ttype in types): return True else: return False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/sqlparse.egg-info/PKG-INFO new/sqlparse-0.2.4/sqlparse.egg-info/PKG-INFO --- old/sqlparse-0.2.3/sqlparse.egg-info/PKG-INFO 2017-03-02 05:48:05.000000000 +0100 +++ new/sqlparse-0.2.4/sqlparse.egg-info/PKG-INFO 2017-09-27 09:09:24.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: sqlparse -Version: 0.2.3 +Version: 0.2.4 Summary: Non-validating SQL parser Home-page: https://github.com/andialbrecht/sqlparse Author: Andi Albrecht diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/sqlparse.egg-info/SOURCES.txt new/sqlparse-0.2.4/sqlparse.egg-info/SOURCES.txt --- old/sqlparse-0.2.3/sqlparse.egg-info/SOURCES.txt 2017-03-02 05:48:05.000000000 +0100 +++ new/sqlparse-0.2.4/sqlparse.egg-info/SOURCES.txt 2017-09-27 09:09:24.000000000 +0200 @@ -50,6 +50,7 @@ tests/test_cli.py tests/test_format.py tests/test_grouping.py +tests/test_keywords.py tests/test_parse.py tests/test_regressions.py tests/test_split.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/tests/test_cli.py new/sqlparse-0.2.4/tests/test_cli.py --- old/sqlparse-0.2.3/tests/test_cli.py 2017-01-23 12:00:01.000000000 +0100 +++ new/sqlparse-0.2.4/tests/test_cli.py 2017-09-24 09:14:11.000000000 +0200 @@ -127,10 +127,11 @@ path = filepath('encoding_gbk.sql') expected = load_file('encoding_gbk.sql', 'gbk') old_stdin = sys.stdin - sys.stdin = open(path, 'r') - sys.stdout.encoding = 'gbk' - sqlparse.cli.main(['-', '--encoding', 'gbk']) - sys.stdin = old_stdin + with open(path, 'r') as stream: + sys.stdin = stream + sys.stdout.encoding = 'gbk' + sqlparse.cli.main(['-', '--encoding', 'gbk']) + sys.stdin = old_stdin out, _ = capfd.readouterr() assert out == expected diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/tests/test_grouping.py new/sqlparse-0.2.4/tests/test_grouping.py --- old/sqlparse-0.2.3/tests/test_grouping.py 2017-03-02 05:34:44.000000000 +0100 +++ new/sqlparse-0.2.4/tests/test_grouping.py 2017-09-24 08:49:44.000000000 +0200 @@ -65,6 +65,20 @@ @pytest.mark.parametrize('s', [ + '1 as f', + 'foo as f', + 'foo f', + '1/2 as f', + '1/2 f', + '1<2 as f', # issue327 + '1<2 f', +]) +def test_simple_identifiers(s): + parsed = sqlparse.parse(s)[0] + assert isinstance(parsed.tokens[0], sql.Identifier) + + [email protected]('s', [ 'foo, bar', 'sum(a), sum(b)', 'sum(a) as x, b as y', @@ -202,6 +216,15 @@ assert isinstance(p.tokens[-1].tokens[0].tokens[-2], sql.Where) [email protected]('s', ( + 'select 1 where 1 = 2 union select 2', + 'select 1 where 1 = 2 union all select 2', +)) +def test_grouping_where_union(s): + p = sqlparse.parse(s)[0] + assert p.tokens[5].value.startswith('union') + + def test_returning_kw_ends_where_clause(): s = 'delete from foo where x > y returning z' p = sqlparse.parse(s)[0] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/tests/test_keywords.py new/sqlparse-0.2.4/tests/test_keywords.py --- old/sqlparse-0.2.3/tests/test_keywords.py 1970-01-01 01:00:00.000000000 +0100 +++ new/sqlparse-0.2.4/tests/test_keywords.py 2017-09-21 10:23:49.000000000 +0200 @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- +import pytest + +from sqlparse import tokens +from sqlparse.keywords import SQL_REGEX + + +class TestSQLREGEX: + @pytest.mark.parametrize('number', ['1.0', '-1.0', + '1.', '-1.', + '.1', '-.1']) + def test_float_numbers(self, number): + ttype = next(tt for action, tt in SQL_REGEX if action(number)) + assert tokens.Number.Float == ttype diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/tests/test_parse.py new/sqlparse-0.2.4/tests/test_parse.py --- old/sqlparse-0.2.3/tests/test_parse.py 2017-01-23 12:00:01.000000000 +0100 +++ new/sqlparse-0.2.4/tests/test_parse.py 2017-05-25 08:51:05.000000000 +0200 @@ -135,11 +135,14 @@ assert t[2].get_real_name() == 'y' [email protected]('name', ['foo', '_foo']) [email protected]('name', [ + 'foo', '_foo', # issue175 + '1_data', # valid MySQL table name, see issue337 +]) def test_valid_identifier_names(name): - # issue175 t = sqlparse.parse(name)[0].tokens assert isinstance(t[0], sql.Identifier) + assert t[0].get_name() == name def test_psql_quotation_marks(): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sqlparse-0.2.3/tests/test_regressions.py new/sqlparse-0.2.4/tests/test_regressions.py --- old/sqlparse-0.2.3/tests/test_regressions.py 2017-02-13 13:45:39.000000000 +0100 +++ new/sqlparse-0.2.4/tests/test_regressions.py 2017-09-24 08:58:55.000000000 +0200 @@ -186,9 +186,9 @@ def test_stream(get_stream): - stream = get_stream("stream.sql") - p = sqlparse.parse(stream)[0] - assert p.get_type() == 'INSERT' + with get_stream("stream.sql") as stream: + p = sqlparse.parse(stream)[0] + assert p.get_type() == 'INSERT' def test_issue90(): @@ -238,9 +238,9 @@ def test_issue190_open_file(filepath): path = filepath('stream.sql') - stream = open(path) - p = sqlparse.parse(stream)[0] - assert p.get_type() == 'INSERT' + with open(path) as stream: + p = sqlparse.parse(stream)[0] + assert p.get_type() == 'INSERT' def test_issue193_splitting_function(): @@ -356,3 +356,13 @@ assert p.tokens[4].value == 'CONCURRENTLY' assert isinstance(p.tokens[6], sql.Identifier) assert p.tokens[6].value == 'myindex' + + [email protected]('s', [ + 'SELECT @min_price:=MIN(price), @max_price:=MAX(price) FROM shop;', + 'SELECT @min_price:=MIN(price), @max_price:=MAX(price) FROM shop', + +]) +def test_issue359_index_error_assignments(s): + sqlparse.parse(s) + sqlparse.format(s, strip_comments=True)
