Skip to content

Commit 1995a8c

Browse files
authored
Merge branch 'master' into mmolinaro/fix-543
2 parents 8362373 + d8f8147 commit 1995a8c

20 files changed

+250
-101
lines changed

.flake8

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[flake8]
2+
exclude =
3+
tests,
4+
docs,
5+
dist
6+
max-complexity = 31
7+
statistics = True
8+
show-source = True

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343

4444
# Initializes the CodeQL tools for scanning.
4545
- name: Initialize CodeQL
46-
uses: github/codeql-action/init@v2
46+
uses: github/codeql-action/init@v3
4747
with:
4848
languages: ${{ matrix.language }}
4949
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +54,7 @@ jobs:
5454
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5555
# If this step fails, then you should remove it and run the build manually (see below)
5656
- name: Autobuild
57-
uses: github/codeql-action/autobuild@v2
57+
uses: github/codeql-action/autobuild@v3
5858

5959
# ℹ️ Command-line programs to run using the OS shell.
6060
# 📚 https://git.io/JvXDl
@@ -68,4 +68,4 @@ jobs:
6868
# make release
6969

7070
- name: Perform CodeQL Analysis
71-
uses: github/codeql-action/analyze@v2
71+
uses: github/codeql-action/analyze@v3

.github/workflows/python-app.yml

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,34 @@ on:
1515
jobs:
1616
test:
1717
name: Run tests on ${{ matrix.py }}
18-
runs-on: ubuntu-20.04 # keep it on 20.04 to have Python 3.6 available
18+
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
2121
py:
22+
#- "3.13-dev"
2223
- "3.12"
2324
- "3.11"
2425
- "3.10"
2526
- "3.9"
2627
- "3.8"
27-
- "3.7"
28-
- "3.6"
28+
- "pypy-3.10"
2929
- "pypy-3.9"
3030
- "pypy-3.8"
31-
- "pypy-3.7"
3231

3332
steps:
3433
- uses: actions/checkout@v4
3534
- name: Set up Python ${{ matrix.py }}
36-
uses: actions/setup-python@v4
35+
uses: actions/setup-python@v5
3736
with:
3837
python-version: ${{ matrix.py }}
3938
allow-prereleases: true
4039
check-latest: true
4140
- name: Install dependencies
4241
run: |
43-
python -m pip install --upgrade pip flit
44-
flit install --deps=develop
42+
python -m pip install --upgrade pip hatch
4543
- name: Lint with flake8
46-
run: flake8 sqlparse --count --max-complexity=31 --show-source --statistics
47-
- name: Test with pytest
48-
run: pytest --cov=sqlparse
44+
run: hatch run flake8
45+
- name: Test with pytest and coverage
46+
run: hatch run cov
4947
- name: Publish to codecov
50-
uses: codecov/codecov-action@v3
48+
uses: codecov/codecov-action@v4

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ dist/
44
build/
55
MANIFEST
66
.coverage
7-
.tox/
87
.cache/
98
*.egg-info/
109
htmlcov/
11-
coverage.xml
1210
.pytest_cache

.readthedocs.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Read the Docs configuration file for Sphinx projects
2+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
3+
4+
# Required
5+
version: 2
6+
7+
# Set the OS, Python version and other tools you might need
8+
build:
9+
os: ubuntu-22.04
10+
tools:
11+
python: "3.12"
12+
# You can also specify other tool versions:
13+
# nodejs: "20"
14+
# rust: "1.70"
15+
# golang: "1.20"
16+
17+
# Build documentation in the "docs/" directory with Sphinx
18+
sphinx:
19+
configuration: docs/source/conf.py
20+
# You can configure Sphinx to use a different builder, for instance use the dirhtml builder for simpler URLs
21+
# builder: "dirhtml"
22+
# Fail on all warnings to avoid broken references
23+
# fail_on_warning: true
24+
25+
# Optionally build your docs in additional formats such as PDF and ePub
26+
# formats:
27+
# - pdf
28+
# - epub
29+
30+
# Optional but recommended, declare the Python requirements required
31+
# to build your documentation
32+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
33+
# python:
34+
# install:
35+
# - requirements: docs/requirements.txt

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ project: https://bitbucket.org/gutworth/six.
88

99
Alphabetical list of contributors:
1010
* Adam Greenhall <agreenhall@lyft.com>
11+
* Adam Johnson <me@adamj.eu>
1112
* Aki Ariga <chezou+github@gmail.com>
1213
* Alexander Beedie <ayembee@gmail.com>
1314
* Alexey Malyshev <nostrict@gmail.com>
@@ -32,6 +33,7 @@ Alphabetical list of contributors:
3233
* Fredy Wijaya <fredy.wijaya@gmail.com>
3334
* Gavin Wahl <gwahl@fusionbox.com>
3435
* Georg Traar <georg@crate.io>
36+
* griff <70294474+griffatrasgo@users.noreply.github.com>
3537
* Hugo van Kemenade <hugovk@users.noreply.github.com>
3638
* hurcy <cinyoung.hur@gmail.com>
3739
* Ian Robertson <ian.robertson@capitalone.com>

CHANGELOG

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@ Development Version
33

44
Notable Changes
55

6-
* Drop support for Python 3.5.
6+
* Drop support for Python 3.5, 3.6, and 3.7.
77
* Python 3.12 is now supported (pr725, by hugovk).
88

99
Enhancements:
1010

1111
* Splitting statements now allows to remove the semicolon at the end.
1212
Some database backends love statements without semicolon (issue742).
1313
* Support TypedLiterals in get_parameters (pr649, by Khrol).
14+
* Improve splitting of Transact SQL when using GO keyword (issue762).
15+
* Support for some JSON operators (issue682).
16+
* Improve formatting of statements containing JSON operators (issue542).
17+
* Support for BigQuery and Snowflake keywords (pr699, by griffatrasgo).
1418

1519
Bug Fixes
1620

1721
* Ignore dunder attributes when creating Tokens (issue672).
1822
* Allow operators to precede dollar-quoted strings (issue763).
1923
* Fix parsing of nested order clauses (issue745, pr746 by john-bodley).
24+
* Thread-safe initialization of Lexer class (issue730).
25+
* Classify TRUNCATE as DDL and GRANT/REVOKE as DCL keywords (based on pr719
26+
by josuc1, thanks for bringing this up!).
27+
* Fix parsing of PRIMARY KEY (issue740).
28+
29+
Other
30+
31+
* Optimize performance of matching function (pr799, by admachainz).
2032

2133

2234
Release 0.4.4 (Apr 18, 2023)

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ python-sqlparse - Parse SQL statements
1111
sqlparse is a non-validating SQL parser for Python.
1212
It provides support for parsing, splitting and formatting SQL statements.
1313

14-
The module is compatible with Python 3.6+ and released under the terms of the
14+
The module is compatible with Python 3.8+ and released under the terms of the
1515
`New BSD license <https://opensource.org/licenses/BSD-3-Clause>`_.
1616

1717
Visit the project page at https://github.com/andialbrecht/sqlparse for

pyproject.toml

Lines changed: 53 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["flit_core >=3.2,<4"]
3-
build-backend = "flit_core.buildapi"
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "sqlparse"
@@ -16,8 +16,6 @@ classifiers = [
1616
"Programming Language :: Python",
1717
"Programming Language :: Python :: 3",
1818
"Programming Language :: Python :: 3 :: Only",
19-
"Programming Language :: Python :: 3.6",
20-
"Programming Language :: Python :: 3.7",
2119
"Programming Language :: Python :: 3.8",
2220
"Programming Language :: Python :: 3.9",
2321
"Programming Language :: Python :: 3.10",
@@ -28,7 +26,7 @@ classifiers = [
2826
"Topic :: Database",
2927
"Topic :: Software Development",
3028
]
31-
requires-python = ">=3.6"
29+
requires-python = ">=3.8"
3230

3331
[project.urls]
3432
Home = "https://github.com/andialbrecht/sqlparse"
@@ -42,35 +40,63 @@ sqlformat = "sqlparse.__main__:main"
4240

4341
[project.optional-dependencies]
4442
dev = [
45-
"importlib_metadata<5; python_version <= '3.7'",
46-
"flake8",
43+
"hatch",
4744
"build",
4845
]
49-
test = [
50-
"pytest",
51-
"pytest-cov",
52-
]
5346
doc = [
5447
"sphinx",
5548
]
56-
tox = [
57-
"virtualenv<20.22.0", # 20.22.0 dropped Python 3.6 support
58-
"tox<4.5.0", # >=4.5.0 requires virtualenv>=20.22
49+
50+
[tool.hatch.version]
51+
path = "sqlparse/__init__.py"
52+
53+
[tool.hatch.envs.default]
54+
dependencies = [
55+
"coverage[toml]>=6.5",
56+
"pytest",
57+
# switch to ruff, but fix problems first
58+
# but check defaults!
59+
# https://hatch.pypa.io/1.9/config/static-analysis/#default-settings
60+
"flake8",
61+
]
62+
[tool.hatch.envs.default.scripts]
63+
test = "pytest {args:tests}"
64+
test-cov = "coverage run -m pytest {args:tests}"
65+
cov-report = [
66+
"- coverage combine",
67+
"coverage report",
68+
]
69+
cov = [
70+
"test-cov",
71+
"cov-report",
5972
]
73+
check = "flake8 sqlparse/"
6074

61-
[tool.flit.sdist]
62-
include = [
63-
"docs/source/",
64-
"docs/sqlformat.1",
65-
"docs/Makefile",
66-
"tests/*.py", "tests/files/*.sql",
67-
"LICENSE",
68-
"TODO",
69-
"AUTHORS",
70-
"CHANGELOG",
71-
"Makefile",
72-
"tox.ini",
75+
[[tool.hatch.envs.all.matrix]]
76+
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
77+
78+
[tool.hatch.envs.types]
79+
dependencies = [
80+
"mypy>=1.0.0",
7381
]
82+
[tool.hatch.envs.types.scripts]
83+
check = "mypy --install-types --non-interactive {args:sqlparse tests}"
7484

7585
[tool.coverage.run]
76-
omit = ["sqlparse/__main__.py"]
86+
source_pkgs = ["sqlparse", "tests"]
87+
branch = true
88+
parallel = true
89+
omit = [
90+
"sqlparse/__main__.py",
91+
]
92+
93+
[tool.coverage.paths]
94+
sqlparse = ["sqlparse"]
95+
tests = ["tests"]
96+
97+
[tool.coverage.report]
98+
exclude_lines = [
99+
"no cov",
100+
"if __name__ == .__main__.:",
101+
"if TYPE_CHECKING:",
102+
]

sqlparse/engine/grouping.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,12 @@ def post(tlist, pidx, tidx, nidx):
139139

140140
def group_period(tlist):
141141
def match(token):
142-
return token.match(T.Punctuation, '.')
142+
for ttype, value in ((T.Punctuation, '.'),
143+
(T.Operator, '->'),
144+
(T.Operator, '->>')):
145+
if token.match(ttype, value):
146+
return True
147+
return False
143148

144149
def valid_prev(token, idx):
145150
sqlcls = sql.SquareBrackets, sql.Identifier
@@ -153,7 +158,7 @@ def valid_next(token, idx):
153158
def post(tlist, pidx, tidx, nidx):
154159
# next_ validation is being performed here. issue261
155160
sqlcls = sql.SquareBrackets, sql.Function
156-
ttypes = T.Name, T.String.Symbol, T.Wildcard
161+
ttypes = T.Name, T.String.Symbol, T.Wildcard, T.String.Single
157162
next_ = tlist[nidx] if nidx is not None else None
158163
valid_next = imt(next_, i=sqlcls, t=ttypes)
159164

0 commit comments

Comments
 (0)