sqlalign 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- sqlalign-1.0.1/.github/workflows/ci.yml +68 -0
- sqlalign-1.0.1/.github/workflows/release.yml +103 -0
- sqlalign-1.0.1/.gitignore +24 -0
- sqlalign-1.0.1/.sqlfluff +199 -0
- sqlalign-1.0.1/CHANGELOG.md +82 -0
- sqlalign-1.0.1/CONTRIBUTING.md +74 -0
- sqlalign-1.0.1/LICENSE +21 -0
- sqlalign-1.0.1/PKG-INFO +404 -0
- sqlalign-1.0.1/README.md +375 -0
- sqlalign-1.0.1/docs/.nojekyll +0 -0
- sqlalign-1.0.1/docs/CNAME +1 -0
- sqlalign-1.0.1/docs/guide/README.md +27 -0
- sqlalign-1.0.1/docs/guide/architecture.md +468 -0
- sqlalign-1.0.1/docs/guide/cli.md +397 -0
- sqlalign-1.0.1/docs/guide/configuration.md +554 -0
- sqlalign-1.0.1/docs/guide/dialects.md +514 -0
- sqlalign-1.0.1/docs/guide/faq.md +424 -0
- sqlalign-1.0.1/docs/guide/getting-started.md +542 -0
- sqlalign-1.0.1/docs/guide/style.md +983 -0
- sqlalign-1.0.1/docs/index.html +460 -0
- sqlalign-1.0.1/docs/sql-style-guide.md +569 -0
- sqlalign-1.0.1/docs/v1/architecture.html +847 -0
- sqlalign-1.0.1/docs/v1/cli.html +850 -0
- sqlalign-1.0.1/docs/v1/configuration.html +1031 -0
- sqlalign-1.0.1/docs/v1/dialects.html +837 -0
- sqlalign-1.0.1/docs/v1/faq.html +765 -0
- sqlalign-1.0.1/docs/v1/getting-started.html +782 -0
- sqlalign-1.0.1/docs/v1/index.html +377 -0
- sqlalign-1.0.1/docs/v1/search-index.json +1 -0
- sqlalign-1.0.1/docs/v1/settings.html +890 -0
- sqlalign-1.0.1/docs/v1/style.html +1212 -0
- sqlalign-1.0.1/pyproject.toml +75 -0
- sqlalign-1.0.1/samples/queries.sql +416 -0
- sqlalign-1.0.1/scripts/build_fixtures.py +23 -0
- sqlalign-1.0.1/src/sqlalign/__init__.py +10 -0
- sqlalign-1.0.1/src/sqlalign/align.py +145 -0
- sqlalign-1.0.1/src/sqlalign/bodylint.py +125 -0
- sqlalign-1.0.1/src/sqlalign/casing.py +182 -0
- sqlalign-1.0.1/src/sqlalign/cli.py +360 -0
- sqlalign-1.0.1/src/sqlalign/commas.py +58 -0
- sqlalign-1.0.1/src/sqlalign/config.py +28 -0
- sqlalign-1.0.1/src/sqlalign/configfile.py +194 -0
- sqlalign-1.0.1/src/sqlalign/formatter.py +609 -0
- sqlalign-1.0.1/src/sqlalign/gui.py +721 -0
- sqlalign-1.0.1/src/sqlalign/ir.py +38 -0
- sqlalign-1.0.1/src/sqlalign/keywordcase.py +127 -0
- sqlalign-1.0.1/src/sqlalign/layout/__init__.py +312 -0
- sqlalign-1.0.1/src/sqlalign/layout/case.py +222 -0
- sqlalign-1.0.1/src/sqlalign/layout/comments.py +530 -0
- sqlalign-1.0.1/src/sqlalign/layout/conditions.py +344 -0
- sqlalign-1.0.1/src/sqlalign/layout/cte.py +81 -0
- sqlalign-1.0.1/src/sqlalign/layout/ddl.py +424 -0
- sqlalign-1.0.1/src/sqlalign/layout/dml.py +287 -0
- sqlalign-1.0.1/src/sqlalign/layout/expr.py +119 -0
- sqlalign-1.0.1/src/sqlalign/layout/fromjoin.py +310 -0
- sqlalign-1.0.1/src/sqlalign/layout/grouporder.py +135 -0
- sqlalign-1.0.1/src/sqlalign/layout/select.py +523 -0
- sqlalign-1.0.1/src/sqlalign/layout/setop.py +78 -0
- sqlalign-1.0.1/src/sqlalign/layout/subquery.py +245 -0
- sqlalign-1.0.1/src/sqlalign/layout/window.py +207 -0
- sqlalign-1.0.1/src/sqlalign/lint.py +173 -0
- sqlalign-1.0.1/src/sqlalign/plpgsql.py +437 -0
- sqlalign-1.0.1/src/sqlalign/splitter.py +241 -0
- sqlalign-1.0.1/src/sqlalign/sqlfluffconfig.py +88 -0
- sqlalign-1.0.1/src/sqlalign/style.py +215 -0
- sqlalign-1.0.1/src/sqlalign/templating.py +87 -0
- sqlalign-1.0.1/tests/conftest.py +20 -0
- sqlalign-1.0.1/tests/fixtures/docs/dbt.sql +4 -0
- sqlalign-1.0.1/tests/fixtures/docs/fromblock.sql +5 -0
- sqlalign-1.0.1/tests/fixtures/docs/hero.sql +10 -0
- sqlalign-1.0.1/tests/fixtures/docs/plpgsql.sql +9 -0
- sqlalign-1.0.1/tests/fixtures/expected/01.sql +11 -0
- sqlalign-1.0.1/tests/fixtures/expected/02.sql +15 -0
- sqlalign-1.0.1/tests/fixtures/expected/03.sql +13 -0
- sqlalign-1.0.1/tests/fixtures/expected/04.sql +11 -0
- sqlalign-1.0.1/tests/fixtures/expected/05.sql +13 -0
- sqlalign-1.0.1/tests/fixtures/expected/06.sql +23 -0
- sqlalign-1.0.1/tests/fixtures/expected/07.sql +16 -0
- sqlalign-1.0.1/tests/fixtures/expected/08.sql +16 -0
- sqlalign-1.0.1/tests/fixtures/expected/09.sql +10 -0
- sqlalign-1.0.1/tests/fixtures/expected/10.sql +21 -0
- sqlalign-1.0.1/tests/fixtures/expected/11.sql +20 -0
- sqlalign-1.0.1/tests/fixtures/expected/12.sql +7 -0
- sqlalign-1.0.1/tests/fixtures/expected/13.sql +15 -0
- sqlalign-1.0.1/tests/fixtures/expected/14.sql +9 -0
- sqlalign-1.0.1/tests/fixtures/expected/15.sql +10 -0
- sqlalign-1.0.1/tests/fixtures/expected/16.sql +8 -0
- sqlalign-1.0.1/tests/fixtures/expected/17.sql +10 -0
- sqlalign-1.0.1/tests/fixtures/expected/18.sql +9 -0
- sqlalign-1.0.1/tests/fixtures/expected/19.sql +23 -0
- sqlalign-1.0.1/tests/fixtures/expected/20.sql +35 -0
- sqlalign-1.0.1/tests/fixtures/expected/21.sql +7 -0
- sqlalign-1.0.1/tests/fixtures/expected/22.sql +22 -0
- sqlalign-1.0.1/tests/fixtures/expected/23.sql +4 -0
- sqlalign-1.0.1/tests/fixtures/expected/24.sql +4 -0
- sqlalign-1.0.1/tests/fixtures/expected/25.sql +5 -0
- sqlalign-1.0.1/tests/fixtures/expected/26.sql +9 -0
- sqlalign-1.0.1/tests/fixtures/expected/27.sql +8 -0
- sqlalign-1.0.1/tests/fixtures/expected/28.sql +21 -0
- sqlalign-1.0.1/tests/fixtures/expected/29.sql +11 -0
- sqlalign-1.0.1/tests/fixtures/input/01.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/02.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/03.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/04.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/05.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/06.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/07.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/08.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/09.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/10.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/11.sql +3 -0
- sqlalign-1.0.1/tests/fixtures/input/12.sql +3 -0
- sqlalign-1.0.1/tests/fixtures/input/13.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/14.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/15.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/16.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/17.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/18.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/19.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/20.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/21.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/22.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/23.sql +3 -0
- sqlalign-1.0.1/tests/fixtures/input/24.sql +3 -0
- sqlalign-1.0.1/tests/fixtures/input/25.sql +5 -0
- sqlalign-1.0.1/tests/fixtures/input/26.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/27.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/28.sql +2 -0
- sqlalign-1.0.1/tests/fixtures/input/29.sql +5 -0
- sqlalign-1.0.1/tests/test_align.py +115 -0
- sqlalign-1.0.1/tests/test_align_off.py +80 -0
- sqlalign-1.0.1/tests/test_align_targets.py +157 -0
- sqlalign-1.0.1/tests/test_ast_equiv.py +13 -0
- sqlalign-1.0.1/tests/test_axis_matrix.py +186 -0
- sqlalign-1.0.1/tests/test_blank_lines.py +112 -0
- sqlalign-1.0.1/tests/test_bodylint.py +200 -0
- sqlalign-1.0.1/tests/test_boolean_position.py +157 -0
- sqlalign-1.0.1/tests/test_casing.py +51 -0
- sqlalign-1.0.1/tests/test_clause_order.py +96 -0
- sqlalign-1.0.1/tests/test_clauses.py +47 -0
- sqlalign-1.0.1/tests/test_cli.py +125 -0
- sqlalign-1.0.1/tests/test_comma_joins_lateral_udf.py +149 -0
- sqlalign-1.0.1/tests/test_comma_position.py +142 -0
- sqlalign-1.0.1/tests/test_comment_and_procedure_bugs.py +158 -0
- sqlalign-1.0.1/tests/test_comments.py +172 -0
- sqlalign-1.0.1/tests/test_comments_in_predicates.py +257 -0
- sqlalign-1.0.1/tests/test_configfile.py +262 -0
- sqlalign-1.0.1/tests/test_construct_sweep.py +259 -0
- sqlalign-1.0.1/tests/test_coverage_round_2.py +196 -0
- sqlalign-1.0.1/tests/test_ddl.py +46 -0
- sqlalign-1.0.1/tests/test_dialect_guard.py +110 -0
- sqlalign-1.0.1/tests/test_distinct.py +133 -0
- sqlalign-1.0.1/tests/test_dml.py +31 -0
- sqlalign-1.0.1/tests/test_docs_examples.py +153 -0
- sqlalign-1.0.1/tests/test_docs_site.py +199 -0
- sqlalign-1.0.1/tests/test_expr.py +152 -0
- sqlalign-1.0.1/tests/test_fetch_and_lateral_subquery.py +151 -0
- sqlalign-1.0.1/tests/test_file_selection.py +147 -0
- sqlalign-1.0.1/tests/test_fromjoin.py +47 -0
- sqlalign-1.0.1/tests/test_golden.py +22 -0
- sqlalign-1.0.1/tests/test_gui.py +1229 -0
- sqlalign-1.0.1/tests/test_keyword_case.py +165 -0
- sqlalign-1.0.1/tests/test_knob_combinations.py +156 -0
- sqlalign-1.0.1/tests/test_line_endings.py +75 -0
- sqlalign-1.0.1/tests/test_lint_flag.py +159 -0
- sqlalign-1.0.1/tests/test_nested_constructs.py +236 -0
- sqlalign-1.0.1/tests/test_no_silent_declines.py +148 -0
- sqlalign-1.0.1/tests/test_on_placement.py +142 -0
- sqlalign-1.0.1/tests/test_pivot.py +147 -0
- sqlalign-1.0.1/tests/test_plpgsql.py +134 -0
- sqlalign-1.0.1/tests/test_presets.py +194 -0
- sqlalign-1.0.1/tests/test_quoted_column_aliases.py +142 -0
- sqlalign-1.0.1/tests/test_remaining_constructs.py +265 -0
- sqlalign-1.0.1/tests/test_report.py +148 -0
- sqlalign-1.0.1/tests/test_river.py +196 -0
- sqlalign-1.0.1/tests/test_robustness.py +96 -0
- sqlalign-1.0.1/tests/test_safety.py +92 -0
- sqlalign-1.0.1/tests/test_select_placement.py +163 -0
- sqlalign-1.0.1/tests/test_skip.py +39 -0
- sqlalign-1.0.1/tests/test_splitter.py +68 -0
- sqlalign-1.0.1/tests/test_sqlfluff_coexistence.py +196 -0
- sqlalign-1.0.1/tests/test_sqlfluff_gate.py +46 -0
- sqlalign-1.0.1/tests/test_style_knobs.py +105 -0
- sqlalign-1.0.1/tests/test_subquery.py +156 -0
- sqlalign-1.0.1/tests/test_table_alias.py +159 -0
- sqlalign-1.0.1/tests/test_table_names.py +152 -0
- sqlalign-1.0.1/tests/test_templating.py +154 -0
- sqlalign-1.0.1/tests/test_trailing_punctuation.py +113 -0
- sqlalign-1.0.1/tests/test_tsql.py +249 -0
- sqlalign-1.0.1/tests/test_unaliased_tables.py +109 -0
- sqlalign-1.0.1/tests/test_upstream_and_tail.py +249 -0
- sqlalign-1.0.1/tests/test_values_and_joins.py +166 -0
- sqlalign-1.0.1/tests/test_width_off_and_body_blanks.py +134 -0
- sqlalign-1.0.1/tools/build_docs.py +309 -0
- sqlalign-1.0.1/tools/docs.css +160 -0
- sqlalign-1.0.1/tools/docs.js +155 -0
- sqlalign-1.0.1/tools/docs_settings.py +262 -0
- sqlalign-1.0.1/tools/shots.py +105 -0
- sqlalign-1.0.1/uv.lock +483 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
# A new push supersedes the run in flight. Actions minutes are free for public
|
|
9
|
+
# repositories, but a queue of stale runs still delays the useful one.
|
|
10
|
+
concurrency:
|
|
11
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
jobs:
|
|
18
|
+
test:
|
|
19
|
+
runs-on: ubuntu-latest
|
|
20
|
+
strategy:
|
|
21
|
+
fail-fast: false
|
|
22
|
+
matrix:
|
|
23
|
+
# The versions pyproject claims to support. Both, because a classifier
|
|
24
|
+
# nobody runs is a guess.
|
|
25
|
+
python: ["3.12", "3.13"]
|
|
26
|
+
steps:
|
|
27
|
+
- uses: actions/checkout@v4
|
|
28
|
+
|
|
29
|
+
- uses: astral-sh/setup-uv@v5
|
|
30
|
+
with:
|
|
31
|
+
enable-cache: true
|
|
32
|
+
|
|
33
|
+
- name: Install
|
|
34
|
+
run: uv sync --locked --all-extras
|
|
35
|
+
|
|
36
|
+
- name: Lint
|
|
37
|
+
run: uv run ruff check .
|
|
38
|
+
|
|
39
|
+
- name: Test
|
|
40
|
+
run: uv run pytest -q
|
|
41
|
+
|
|
42
|
+
# The formatter's own output is the product, so a golden that no longer
|
|
43
|
+
# matches is a release blocker rather than a test failure among others. This
|
|
44
|
+
# runs the same assertion the suite does, separately, so the reason a red
|
|
45
|
+
# build is red is visible from the job list.
|
|
46
|
+
goldens:
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
steps:
|
|
49
|
+
- uses: actions/checkout@v4
|
|
50
|
+
- uses: astral-sh/setup-uv@v5
|
|
51
|
+
with:
|
|
52
|
+
enable-cache: true
|
|
53
|
+
- run: uv sync --locked
|
|
54
|
+
- name: Goldens are byte-exact
|
|
55
|
+
run: uv run pytest -q -k goldens_unchanged
|
|
56
|
+
|
|
57
|
+
# docs/v1 is generated and committed, so a stale build ships. Rebuilding here
|
|
58
|
+
# proves the committed site matches its generator.
|
|
59
|
+
docs:
|
|
60
|
+
runs-on: ubuntu-latest
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v4
|
|
63
|
+
- uses: astral-sh/setup-uv@v5
|
|
64
|
+
with:
|
|
65
|
+
enable-cache: true
|
|
66
|
+
- run: uv sync --locked
|
|
67
|
+
- name: Site matches its generator
|
|
68
|
+
run: uv run pytest -q tests/test_docs_site.py
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Publishing runs in two steps, deliberately.
|
|
4
|
+
#
|
|
5
|
+
# 1. Every push of a `v*` tag builds the artifacts and publishes them to
|
|
6
|
+
# TestPyPI, which can be re-uploaded under a fresh version and is where a
|
|
7
|
+
# broken README render or a bad classifier should be found.
|
|
8
|
+
# 2. Publishing to PyPI proper is a manual run of this workflow. A version
|
|
9
|
+
# number on PyPI can never be reused, so that step asks first.
|
|
10
|
+
#
|
|
11
|
+
# Both use Trusted Publishing: PyPI accepts a short-lived OIDC token minted by
|
|
12
|
+
# this workflow instead of a stored API token. Nothing to rotate, nothing to
|
|
13
|
+
# leak. It requires a publisher configured on the PyPI side naming this
|
|
14
|
+
# repository, this filename, and the environment below.
|
|
15
|
+
|
|
16
|
+
on:
|
|
17
|
+
push:
|
|
18
|
+
tags: ["v*"]
|
|
19
|
+
workflow_dispatch:
|
|
20
|
+
inputs:
|
|
21
|
+
target:
|
|
22
|
+
description: "Where to publish"
|
|
23
|
+
required: true
|
|
24
|
+
default: testpypi
|
|
25
|
+
type: choice
|
|
26
|
+
options: [testpypi, pypi]
|
|
27
|
+
|
|
28
|
+
permissions:
|
|
29
|
+
contents: read
|
|
30
|
+
|
|
31
|
+
jobs:
|
|
32
|
+
build:
|
|
33
|
+
runs-on: ubuntu-latest
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- uses: astral-sh/setup-uv@v5
|
|
37
|
+
with:
|
|
38
|
+
enable-cache: true
|
|
39
|
+
|
|
40
|
+
- name: Install
|
|
41
|
+
run: uv sync --locked --all-extras
|
|
42
|
+
|
|
43
|
+
# The artifacts are what ships, so they are checked, not assumed.
|
|
44
|
+
- name: Test
|
|
45
|
+
run: uv run pytest -q
|
|
46
|
+
|
|
47
|
+
- name: Build
|
|
48
|
+
run: uv build
|
|
49
|
+
|
|
50
|
+
- name: Check the artifacts
|
|
51
|
+
run: uvx twine check dist/*
|
|
52
|
+
|
|
53
|
+
# The tag and the packaged version must agree, or the release is named
|
|
54
|
+
# one thing and installs as another.
|
|
55
|
+
- name: Tag matches the package version
|
|
56
|
+
if: startsWith(github.ref, 'refs/tags/v')
|
|
57
|
+
run: |
|
|
58
|
+
tag="${GITHUB_REF_NAME#v}"
|
|
59
|
+
built=$(ls dist/*.tar.gz | sed -E 's/.*sqlalign-(.*)\.tar\.gz/\1/')
|
|
60
|
+
echo "tag=$tag built=$built"
|
|
61
|
+
[ "$tag" = "$built" ] || { echo "::error::tag $tag != version $built"; exit 1; }
|
|
62
|
+
|
|
63
|
+
- uses: actions/upload-artifact@v4
|
|
64
|
+
with:
|
|
65
|
+
name: dist
|
|
66
|
+
path: dist/
|
|
67
|
+
|
|
68
|
+
testpypi:
|
|
69
|
+
needs: build
|
|
70
|
+
if: startsWith(github.ref, 'refs/tags/v') || inputs.target == 'testpypi'
|
|
71
|
+
runs-on: ubuntu-latest
|
|
72
|
+
environment:
|
|
73
|
+
name: testpypi
|
|
74
|
+
url: https://test.pypi.org/p/sqlalign
|
|
75
|
+
permissions:
|
|
76
|
+
id-token: write # required to mint the OIDC token
|
|
77
|
+
steps:
|
|
78
|
+
- uses: actions/download-artifact@v4
|
|
79
|
+
with:
|
|
80
|
+
name: dist
|
|
81
|
+
path: dist/
|
|
82
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
83
|
+
with:
|
|
84
|
+
repository-url: https://test.pypi.org/legacy/
|
|
85
|
+
# A tag re-run should not fail the release over a version that is
|
|
86
|
+
# already on TestPyPI.
|
|
87
|
+
skip-existing: true
|
|
88
|
+
|
|
89
|
+
pypi:
|
|
90
|
+
needs: build
|
|
91
|
+
if: inputs.target == 'pypi'
|
|
92
|
+
runs-on: ubuntu-latest
|
|
93
|
+
environment:
|
|
94
|
+
name: pypi
|
|
95
|
+
url: https://pypi.org/p/sqlalign
|
|
96
|
+
permissions:
|
|
97
|
+
id-token: write
|
|
98
|
+
steps:
|
|
99
|
+
- uses: actions/download-artifact@v4
|
|
100
|
+
with:
|
|
101
|
+
name: dist
|
|
102
|
+
path: dist/
|
|
103
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.pyc
|
|
3
|
+
.pytest_cache/
|
|
4
|
+
.venv
|
|
5
|
+
.venv.nosync/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
*.egg-info/
|
|
9
|
+
.superpowers/
|
|
10
|
+
|
|
11
|
+
# Design notes, plans and research from the build. Kept on disk, out of the
|
|
12
|
+
# repository: they are working documents addressed to one reader, they carry
|
|
13
|
+
# absolute local paths, and they sat inside `docs/` where they would ship with
|
|
14
|
+
# the published site.
|
|
15
|
+
docs/superpowers/
|
|
16
|
+
|
|
17
|
+
# scratch scripts (e.g. from exploratory agents) must not be committed
|
|
18
|
+
/probe_*.py
|
|
19
|
+
|
|
20
|
+
# Agent/assistant working files, if any ever land here
|
|
21
|
+
CLAUDE.md
|
|
22
|
+
AGENTS.md
|
|
23
|
+
.claude/
|
|
24
|
+
.superpowers/
|
sqlalign-1.0.1/.sqlfluff
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
# vim: ft=toml
|
|
2
|
+
|
|
3
|
+
# ref: https://docs.sqlfluff.com/en/stable/rules.html
|
|
4
|
+
# ref: https://levelup.gitconnected.com/sqlfluff-the-best-linter-for-sql-aa358c1eca40
|
|
5
|
+
|
|
6
|
+
[sqlfluff]
|
|
7
|
+
dialect = postgres
|
|
8
|
+
exclude_rules =
|
|
9
|
+
aliasing.unique.table,
|
|
10
|
+
aliasing.unused,
|
|
11
|
+
ambiguous.join,
|
|
12
|
+
ambiguous.order_by,
|
|
13
|
+
convention.not_equal,
|
|
14
|
+
convention.terminator,
|
|
15
|
+
layout.indent,
|
|
16
|
+
layout.keyword_newline,
|
|
17
|
+
layout.operators,
|
|
18
|
+
layout.select_targets,
|
|
19
|
+
layout.spacing,
|
|
20
|
+
postgres.excessive_locks,
|
|
21
|
+
references.keywords,
|
|
22
|
+
references.qualification,
|
|
23
|
+
references.quoting,
|
|
24
|
+
structure.column_order,
|
|
25
|
+
structure.else_null,
|
|
26
|
+
structure.subquery,
|
|
27
|
+
structure.join_condition_order,
|
|
28
|
+
structure.unused_join,
|
|
29
|
+
# --- House-style conflicts (sqlalign preserves the author's valid choices;
|
|
30
|
+
# it aligns and cases, it never rewrites these). Each is a deliberate
|
|
31
|
+
# exclusion, not a formatter bug — see README "sqlfluff gate". ---
|
|
32
|
+
# AM06: house preserves the source GROUP BY/ORDER BY reference form
|
|
33
|
+
# (positional `GROUP BY 1, 2` in #6, named elsewhere) — it does not
|
|
34
|
+
# normalize one query's choice to match another's.
|
|
35
|
+
ambiguous.column_references,
|
|
36
|
+
# AL03: house does not force an alias onto every expression; INSERT ... SELECT
|
|
37
|
+
# source columns (#11) are legitimately unaliased.
|
|
38
|
+
aliasing.expression,
|
|
39
|
+
# CV11: house preserves the source cast form (`::` vs CAST(...)) faithfully
|
|
40
|
+
# (#12 mixes both by design) rather than unifying to one casting style.
|
|
41
|
+
convention.casting_style
|
|
42
|
+
|
|
43
|
+
processes = -2
|
|
44
|
+
# Set this to 120, later;
|
|
45
|
+
max_line_length = -1
|
|
46
|
+
large_file_skip_byte_limit = 0
|
|
47
|
+
max_parse_depth = 512
|
|
48
|
+
|
|
49
|
+
# layout.indent:
|
|
50
|
+
[sqlfluff:indentation]
|
|
51
|
+
indent_unit = space
|
|
52
|
+
tab_space_size = -1
|
|
53
|
+
indented_using_on = True
|
|
54
|
+
indented_on_contents = True
|
|
55
|
+
implicit_indents = forbid
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
[sqlfluff:rules:capitalisation.keywords]
|
|
59
|
+
capitalisation_policy = upper
|
|
60
|
+
#ignore_words = None
|
|
61
|
+
#ignore_words_regex = None
|
|
62
|
+
|
|
63
|
+
[sqlfluff:rules:capitalisation.functions]
|
|
64
|
+
extended_capitalisation_policy = upper
|
|
65
|
+
|
|
66
|
+
# layout.spacing:
|
|
67
|
+
[sqlfluff:layout:type:alias_expression]
|
|
68
|
+
# We want non-default spacing _before_ the alias expressions.
|
|
69
|
+
spacing_before = align
|
|
70
|
+
# We want to align them within the next outer select clause.
|
|
71
|
+
# This means for example that alias expressions within the FROM
|
|
72
|
+
# or JOIN clause would _not_ be aligned with them.
|
|
73
|
+
align_within = select_clause
|
|
74
|
+
# The point at which to stop searching outward for siblings, which
|
|
75
|
+
# in this example would likely be the boundary of a CTE. Stopping
|
|
76
|
+
# when we hit brackets is usually a good rule of thumb for this
|
|
77
|
+
# configuration.
|
|
78
|
+
align_scope = bracketed
|
|
79
|
+
|
|
80
|
+
[sqlfluff:layout:type:comma]
|
|
81
|
+
spacing_before = touch
|
|
82
|
+
line_position = leading
|
|
83
|
+
|
|
84
|
+
[sqlfluff:rules:aliasing.table]
|
|
85
|
+
aliasing = implicit
|
|
86
|
+
|
|
87
|
+
[sqlfluff:rules:capitalisation.literals]
|
|
88
|
+
# Null & Boolean Literals
|
|
89
|
+
capitalisation_policy = upper
|
|
90
|
+
|
|
91
|
+
[sqlfluff:rules:capitalisation.types]
|
|
92
|
+
extended_capitalisation_policy = consistent
|
|
93
|
+
|
|
94
|
+
# layout.spacing:
|
|
95
|
+
[sqlfluff:layout:type:comparison_operator]
|
|
96
|
+
spacing_before = align
|
|
97
|
+
align_within = from_clause
|
|
98
|
+
line_position = leading
|
|
99
|
+
|
|
100
|
+
[sqlfluff:layout:type:assignment_operator]
|
|
101
|
+
spacing_within = touch
|
|
102
|
+
line_position = leading
|
|
103
|
+
|
|
104
|
+
[sqlfluff:layout:type:binary_operator]
|
|
105
|
+
spacing_within = touch
|
|
106
|
+
line_position = leading
|
|
107
|
+
|
|
108
|
+
[sqlfluff:layout:type:statement_terminator]
|
|
109
|
+
spacing_before = touch
|
|
110
|
+
line_position = trailing
|
|
111
|
+
|
|
112
|
+
[sqlfluff:layout:type:end_of_file]
|
|
113
|
+
spacing_before = touch
|
|
114
|
+
|
|
115
|
+
[sqlfluff:layout:type:set_operator]
|
|
116
|
+
line_position = alone:strict
|
|
117
|
+
|
|
118
|
+
[sqlfluff:layout:type:start_bracket]
|
|
119
|
+
spacing_after = touch
|
|
120
|
+
|
|
121
|
+
[sqlfluff:layout:type:end_bracket]
|
|
122
|
+
spacing_before = touch
|
|
123
|
+
|
|
124
|
+
[sqlfluff:layout:type:start_square_bracket]
|
|
125
|
+
spacing_after = touch
|
|
126
|
+
|
|
127
|
+
[sqlfluff:layout:type:end_square_bracket]
|
|
128
|
+
spacing_before = touch
|
|
129
|
+
|
|
130
|
+
[sqlfluff:layout:type:start_angle_bracket]
|
|
131
|
+
spacing_after = touch
|
|
132
|
+
|
|
133
|
+
[sqlfluff:layout:type:end_angle_bracket]
|
|
134
|
+
spacing_before = touch
|
|
135
|
+
|
|
136
|
+
[sqlfluff:layout:type:casting_operator]
|
|
137
|
+
spacing_before = touch
|
|
138
|
+
spacing_after = touch:inline
|
|
139
|
+
|
|
140
|
+
[sqlfluff:layout:type:slice]
|
|
141
|
+
spacing_before = touch
|
|
142
|
+
spacing_after = touch
|
|
143
|
+
|
|
144
|
+
[sqlfluff:layout:type:object_reference]
|
|
145
|
+
spacing_within = touch:inline
|
|
146
|
+
|
|
147
|
+
[sqlfluff:layout:type:numeric_literal]
|
|
148
|
+
spacing_within = touch:inline
|
|
149
|
+
|
|
150
|
+
[sqlfluff:layout:type:sign_indicator]
|
|
151
|
+
spacing_after = touch:inline
|
|
152
|
+
|
|
153
|
+
[sqlfluff:layout:type:function_name]
|
|
154
|
+
spacing_within = touch:inline
|
|
155
|
+
spacing_after = touch:inline
|
|
156
|
+
|
|
157
|
+
[sqlfluff:layout:type:array_type]
|
|
158
|
+
spacing_within = touch:inline
|
|
159
|
+
|
|
160
|
+
[sqlfluff:layout:type:typed_array_literal]
|
|
161
|
+
spacing_within = touch
|
|
162
|
+
|
|
163
|
+
[sqlfluff:layout:type:sized_array_type]
|
|
164
|
+
spacing_within = touch
|
|
165
|
+
|
|
166
|
+
[sqlfluff:layout:type:struct_type]
|
|
167
|
+
spacing_within = touch:inline
|
|
168
|
+
|
|
169
|
+
[sqlfluff:layout:type:data_type]
|
|
170
|
+
spacing_within = touch:inline
|
|
171
|
+
|
|
172
|
+
[sqlfluff:layout:type:typed_struct_literal]
|
|
173
|
+
spacing_within = touch
|
|
174
|
+
|
|
175
|
+
[sqlfluff:layout:type:semi_structured_expression]
|
|
176
|
+
spacing_within = touch:inline
|
|
177
|
+
spacing_before = touch:inline
|
|
178
|
+
|
|
179
|
+
[sqlfluff:layout:type:array_accessor]
|
|
180
|
+
spacing_before = touch:inline
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
[sqlfluff:rules:references.quoting]
|
|
184
|
+
# Policy on quoted and unquoted identifiers
|
|
185
|
+
prefer_quoted_identifiers = False
|
|
186
|
+
ignore_words = None
|
|
187
|
+
ignore_words_regex = None
|
|
188
|
+
|
|
189
|
+
[sqlfluff:rules:layout.long_lines]
|
|
190
|
+
# Line length
|
|
191
|
+
ignore_comment_lines = False
|
|
192
|
+
ignore_comment_clauses = False
|
|
193
|
+
|
|
194
|
+
[sqlfluff:rules:layout.select_targets]
|
|
195
|
+
wildcard_policy = single
|
|
196
|
+
|
|
197
|
+
[sqlfluff:rules:structure.subquery]
|
|
198
|
+
# By default, allow subqueries in from clauses, but not join clauses
|
|
199
|
+
forbid_subquery_in = join
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.1
|
|
4
|
+
|
|
5
|
+
No functional change. `1.0.0` was tagged before the package was ever published,
|
|
6
|
+
so this is the first version to reach an index.
|
|
7
|
+
|
|
8
|
+
## 1.0.0
|
|
9
|
+
|
|
10
|
+
First release.
|
|
11
|
+
|
|
12
|
+
sqlalign formats SQL into a columnar, aligned house style, and re-parses every
|
|
13
|
+
statement it writes to prove it did not change what the SQL means.
|
|
14
|
+
|
|
15
|
+
### The guarantee
|
|
16
|
+
|
|
17
|
+
Every statement is re-parsed after formatting and compared against the input as
|
|
18
|
+
a syntax tree. If the output would differ semantically — or if the engine does
|
|
19
|
+
not fully model the construct — that statement is passed through byte-identical
|
|
20
|
+
with a warning instead, and the run still exits `0`.
|
|
21
|
+
|
|
22
|
+
A passthrough is not a failure. It is what makes the tool safe to run across a
|
|
23
|
+
repository you did not write.
|
|
24
|
+
|
|
25
|
+
### Formatting
|
|
26
|
+
|
|
27
|
+
- **Postgres, Redshift and SQL Server**, selected with `--dialect`. Adding a
|
|
28
|
+
dialect requires auditing every keyword the layout emits, because the AST
|
|
29
|
+
check cannot catch output that is valid SQL but invalid for the target
|
|
30
|
+
engine — so the list is short and deliberate.
|
|
31
|
+
- **plpgsql `$$` bodies are formatted**, statement by statement, rather than
|
|
32
|
+
treated as an opaque string.
|
|
33
|
+
- **Jinja and dbt templating** is masked before parsing, so a templated model
|
|
34
|
+
formats instead of failing to parse.
|
|
35
|
+
- Comments are reproduced faithfully or the statement declines — never moved,
|
|
36
|
+
never restyled.
|
|
37
|
+
|
|
38
|
+
### Configuration
|
|
39
|
+
|
|
40
|
+
- `.sqlalign.toml`, with CLI flags overriding it for a single run.
|
|
41
|
+
- **18 style options**, each documented with the same SQL rendered under each of
|
|
42
|
+
its values.
|
|
43
|
+
- **Six presets**: `house`, `compact`, `trailing`, `dbt`, `gitlab`, `river`. The
|
|
44
|
+
last two reproduce their source style guides byte for byte and are pinned to
|
|
45
|
+
those documents by tests.
|
|
46
|
+
- Alignment is one mechanism with a list of targets, so a team can keep the
|
|
47
|
+
join-condition column and drop the rest — or turn padding off entirely with
|
|
48
|
+
`--no-align` and keep the line structure, which is what most published style
|
|
49
|
+
guides ask for.
|
|
50
|
+
|
|
51
|
+
### Running it
|
|
52
|
+
|
|
53
|
+
- Files or directories, with `--exclude` globs.
|
|
54
|
+
- `--check` for CI, `--diff` to preview, `--stdout` to pipe.
|
|
55
|
+
- `--report` counts what declined and ranks the causes, so a passthrough stops
|
|
56
|
+
being invisible; `--max-declines N` turns that into a gate.
|
|
57
|
+
- `--gui` opens a settings panel with a live preview. **Experimental** — the
|
|
58
|
+
CLI and config file are the supported surface.
|
|
59
|
+
|
|
60
|
+
### Alongside sqlfluff
|
|
61
|
+
|
|
62
|
+
- `--print-sqlfluff-config` generates a config that stops the two tools
|
|
63
|
+
fighting: sqlalign owns layout, so the whole `layout` rule group is excluded
|
|
64
|
+
by name, and every semantic rule stays on.
|
|
65
|
+
- `--lint` runs sqlfluff over the formatted result in the same command.
|
|
66
|
+
- **`--lint` reads inside `$$` bodies, which sqlfluff cannot.** To its parser a
|
|
67
|
+
plpgsql body is a single string literal, so nothing inside one is ever linted.
|
|
68
|
+
sqlalign already locates those statements in order to format them, and hands
|
|
69
|
+
them over with their real line and column numbers.
|
|
70
|
+
|
|
71
|
+
### Known limits
|
|
72
|
+
|
|
73
|
+
These decline rather than guess, and say why:
|
|
74
|
+
|
|
75
|
+
- `PIVOT`/`UNPIVOT` under Postgres, which has no such syntax.
|
|
76
|
+
- T-SQL `IF`/`WHILE` inside a procedure body: sqlglot leaves part of the body
|
|
77
|
+
unparsed, including the whole `ELSE` branch, so laying out the tree would drop
|
|
78
|
+
it silently.
|
|
79
|
+
- A comment buried inside an expression, or in a positional `GROUP BY 1, 2` —
|
|
80
|
+
neither has a row of its own to sit on.
|
|
81
|
+
- Constructs sqlglot cannot parse or cannot round-trip through its own
|
|
82
|
+
generator. `--report` names each one.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for looking. This file covers the three things about this repository that
|
|
4
|
+
are not obvious from the code, and that will otherwise cost you an afternoon.
|
|
5
|
+
|
|
6
|
+
## Setup
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
uv sync # Python 3.12+
|
|
10
|
+
uv run pytest -q # ~3,300 tests, about 40 seconds
|
|
11
|
+
uv run ruff check .
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Both must be clean before a pull request. There is no other gate.
|
|
15
|
+
|
|
16
|
+
## The goldens are the specification
|
|
17
|
+
|
|
18
|
+
`samples/queries.sql` holds hand-formatted SQL, and `tests/fixtures/expected/`
|
|
19
|
+
holds what the formatter must produce for each one — **byte for byte**. They are
|
|
20
|
+
not regression snapshots to be regenerated when they disagree with the code;
|
|
21
|
+
they are the definition of the house style, and the code is what has to change.
|
|
22
|
+
|
|
23
|
+
If a change makes a golden fail, the question is which one is wrong. Usually the
|
|
24
|
+
code. Occasionally the golden, and then it changes deliberately, in its own
|
|
25
|
+
commit, with the reason.
|
|
26
|
+
|
|
27
|
+
A new construct needs a new golden. `scripts/build_fixtures.py` splits
|
|
28
|
+
`samples/queries.sql` into the fixture files after you add a sample.
|
|
29
|
+
|
|
30
|
+
## Two invariants every change must hold
|
|
31
|
+
|
|
32
|
+
**The output must mean what the input meant.** Every statement is re-parsed
|
|
33
|
+
after formatting and compared as a syntax tree; a difference means the statement
|
|
34
|
+
is passed through unchanged instead. If you find a decline whose reason is
|
|
35
|
+
`formatting would change semantics`, that is a **bug in the renderer**, not a
|
|
36
|
+
construct nobody implemented — `tests/test_no_silent_declines.py` exists to
|
|
37
|
+
catch exactly that, and it is worth reading before adding a layout handler.
|
|
38
|
+
|
|
39
|
+
**Formatting must be idempotent.** `format(format(x)) == format(x)`, always. A
|
|
40
|
+
surprising number of layout bugs are only visible on the second pass, so tests
|
|
41
|
+
for anything that moves content between lines should check a fixed point rather
|
|
42
|
+
than a single run.
|
|
43
|
+
|
|
44
|
+
## Declining is a feature
|
|
45
|
+
|
|
46
|
+
A construct the layout does not model is passed through byte-identical with a
|
|
47
|
+
warning, and the run still exits `0`. That is the contract, not a shortcoming —
|
|
48
|
+
it is what makes the tool safe to run across a repository you did not write.
|
|
49
|
+
|
|
50
|
+
When you add a decline, name it. `raise Unsupported("CTE MATERIALIZED")` tells
|
|
51
|
+
`--report` what to count and tells a user what to go and fix; a bare re-raise
|
|
52
|
+
tells them nothing.
|
|
53
|
+
|
|
54
|
+
## The docs are generated
|
|
55
|
+
|
|
56
|
+
`docs/v1/` is built and committed, because GitHub Pages runs no build step.
|
|
57
|
+
Prose lives in `docs/guide/*.md`; the settings examples and the CLI flag table
|
|
58
|
+
are produced by running the formatter and reading the argument parser, so
|
|
59
|
+
neither can drift from the tool.
|
|
60
|
+
|
|
61
|
+
After changing a guide page, a setting, or anything that changes output:
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
uv run python tools/build_docs.py
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
`tests/test_docs_site.py` fails if the committed site does not match what the
|
|
68
|
+
generator produces, so a forgotten rebuild cannot ship.
|
|
69
|
+
|
|
70
|
+
## Style
|
|
71
|
+
|
|
72
|
+
Match the surrounding code. Comments explain what the code is and why it has to
|
|
73
|
+
be that way — not what it used to be, or how a bug was found. That belongs in
|
|
74
|
+
the commit message.
|
sqlalign-1.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Pavan Amin (Lumaru)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|