sqlalign 1.1.0__tar.gz → 1.3.0__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.
Files changed (275) hide show
  1. sqlalign-1.3.0/CHANGELOG.md +481 -0
  2. {sqlalign-1.1.0 → sqlalign-1.3.0}/PKG-INFO +4 -1
  3. {sqlalign-1.1.0 → sqlalign-1.3.0}/README.md +3 -0
  4. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/guide/architecture.md +29 -0
  5. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/guide/cli.md +26 -2
  6. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/guide/configuration.md +5 -9
  7. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/guide/dialects.md +26 -15
  8. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/guide/faq.md +22 -0
  9. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/guide/getting-started.md +28 -1
  10. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/architecture.html +28 -1
  11. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/cli.html +27 -5
  12. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/configuration.html +16 -7
  13. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/dialects.html +22 -13
  14. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/faq.html +21 -2
  15. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/getting-started.html +22 -3
  16. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/index.html +1 -1
  17. sqlalign-1.3.0/docs/v1/search-index.json +1 -0
  18. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/settings.html +1 -1
  19. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/v1/style.html +1 -1
  20. {sqlalign-1.1.0 → sqlalign-1.3.0}/pyproject.toml +1 -1
  21. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/casing.py +70 -1
  22. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/cli.py +113 -7
  23. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/configfile.py +27 -4
  24. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/formatter.py +189 -13
  25. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/keywordcase.py +17 -2
  26. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/__init__.py +54 -3
  27. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/comments.py +5 -2
  28. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/ddl.py +30 -2
  29. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/grouporder.py +28 -3
  30. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/lint.py +9 -2
  31. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/plpgsql.py +151 -18
  32. sqlalign-1.3.0/src/sqlalign/sourcecase.py +90 -0
  33. sqlalign-1.3.0/src/sqlalign/spelling.py +183 -0
  34. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/splitter.py +15 -1
  35. sqlalign-1.3.0/tests/test_body_census.py +116 -0
  36. sqlalign-1.3.0/tests/test_body_comments.py +110 -0
  37. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_construct_sweep.py +4 -1
  38. sqlalign-1.3.0/tests/test_decline_naming.py +106 -0
  39. sqlalign-1.3.0/tests/test_dialect_config.py +129 -0
  40. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_docs_site.py +68 -0
  41. sqlalign-1.3.0/tests/test_dollar_tags.py +203 -0
  42. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_fetch_and_lateral_subquery.py +2 -2
  43. sqlalign-1.3.0/tests/test_line_ranges.py +114 -0
  44. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_lint_flag.py +51 -0
  45. sqlalign-1.3.0/tests/test_literal_spelling.py +132 -0
  46. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_packaging.py +10 -5
  47. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_plpgsql.py +15 -2
  48. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_positioning.py +17 -0
  49. sqlalign-1.3.0/tests/test_rewrite_guard.py +160 -0
  50. sqlalign-1.3.0/tests/test_source_casing.py +115 -0
  51. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_tsql.py +26 -1
  52. {sqlalign-1.1.0 → sqlalign-1.3.0}/uv.lock +1 -1
  53. sqlalign-1.1.0/CHANGELOG.md +0 -222
  54. sqlalign-1.1.0/docs/v1/search-index.json +0 -1
  55. sqlalign-1.1.0/tests/test_body_comments.py +0 -73
  56. {sqlalign-1.1.0 → sqlalign-1.3.0}/.github/workflows/ci.yml +0 -0
  57. {sqlalign-1.1.0 → sqlalign-1.3.0}/.github/workflows/release.yml +0 -0
  58. {sqlalign-1.1.0 → sqlalign-1.3.0}/.gitignore +0 -0
  59. {sqlalign-1.1.0 → sqlalign-1.3.0}/.pre-commit-hooks.yaml +0 -0
  60. {sqlalign-1.1.0 → sqlalign-1.3.0}/.sqlfluff +0 -0
  61. {sqlalign-1.1.0 → sqlalign-1.3.0}/CONTRIBUTING.md +0 -0
  62. {sqlalign-1.1.0 → sqlalign-1.3.0}/LICENSE +0 -0
  63. {sqlalign-1.1.0 → sqlalign-1.3.0}/action.yml +0 -0
  64. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/guide/README.md +0 -0
  65. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/guide/style.md +0 -0
  66. {sqlalign-1.1.0 → sqlalign-1.3.0}/docs/index.html +0 -0
  67. {sqlalign-1.1.0 → sqlalign-1.3.0}/samples/queries.sql +0 -0
  68. {sqlalign-1.1.0 → sqlalign-1.3.0}/scripts/build_fixtures.py +0 -0
  69. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/__init__.py +0 -0
  70. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/align.py +0 -0
  71. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/bodylint.py +0 -0
  72. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/commas.py +0 -0
  73. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/config.py +0 -0
  74. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/gui.py +0 -0
  75. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/ir.py +0 -0
  76. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/case.py +0 -0
  77. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/conditions.py +0 -0
  78. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/cte.py +0 -0
  79. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/dml.py +0 -0
  80. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/expr.py +0 -0
  81. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/fromjoin.py +0 -0
  82. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/select.py +0 -0
  83. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/setop.py +0 -0
  84. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/subquery.py +0 -0
  85. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/layout/window.py +0 -0
  86. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/py.typed +0 -0
  87. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/sqlfluffconfig.py +0 -0
  88. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/style.py +0 -0
  89. {sqlalign-1.1.0 → sqlalign-1.3.0}/src/sqlalign/templating.py +0 -0
  90. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/conftest.py +0 -0
  91. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/README.md +0 -0
  92. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__math__log_natural.sql +0 -0
  93. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__math__median.sql +0 -0
  94. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__math__percentile_cont.sql +0 -0
  95. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__math__rand.sql +0 -0
  96. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__regex__regexp_instr.sql +0 -0
  97. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized___ignore_row_if_expression.sql +0 -0
  98. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized___truth_expression.sql +0 -0
  99. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized__equal_expression.sql +0 -0
  100. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized__expression_between.sql +0 -0
  101. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized__expression_is_true.sql +0 -0
  102. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_count_to_be_greater_than.sql +0 -0
  103. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_count_to_be_less_than.sql +0 -0
  104. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_count_to_equal.sql +0 -0
  105. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_count_to_equal_other_table.sql +0 -0
  106. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_values_to_be_in_set.sql +0 -0
  107. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_values_to_contain_set.sql +0 -0
  108. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_values_to_equal_set.sql +0 -0
  109. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_max_to_be_between.sql +0 -0
  110. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_mean_to_be_between.sql +0 -0
  111. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_median_to_be_between.sql +0 -0
  112. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_min_to_be_between.sql +0 -0
  113. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_most_common_value_to_be_in_set.sql +0 -0
  114. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_proportion_of_unique_values_to_be_between.sql +0 -0
  115. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_quantile_values_to_be_between.sql +0 -0
  116. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_stdev_to_be_between.sql +0 -0
  117. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_sum_to_be_between.sql +0 -0
  118. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_unique_value_count_to_be_between.sql +0 -0
  119. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_between.sql +0 -0
  120. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_decreasing.sql +0 -0
  121. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_in_set.sql +0 -0
  122. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_in_type_list.sql +0 -0
  123. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_increasing.sql +0 -0
  124. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_null.sql +0 -0
  125. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_of_type.sql +0 -0
  126. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_unique.sql +0 -0
  127. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_have_consistent_casing.sql +0 -0
  128. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_not_be_in_set.sql +0 -0
  129. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_not_be_null.sql +0 -0
  130. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__distributional__expect_column_values_to_be_within_n_moving_stdevs.sql +0 -0
  131. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__distributional__expect_column_values_to_be_within_n_stdevs.sql +0 -0
  132. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__customers.sql +0 -0
  133. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__orders.sql +0 -0
  134. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__staging__stg_customers.sql +0 -0
  135. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__staging__stg_orders.sql +0 -0
  136. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__staging__stg_payments.sql +0 -0
  137. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/sqlglot/tests__fixtures__identity.sql +0 -0
  138. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/sqlglot/tests__fixtures__optimizer__optimizer.sql +0 -0
  139. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/corpus/sqlglot/tests__fixtures__pretty.sql +0 -0
  140. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/docs/dbt.sql +0 -0
  141. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/docs/fromblock.sql +0 -0
  142. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/docs/hero.sql +0 -0
  143. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/docs/plpgsql.sql +0 -0
  144. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/01.sql +0 -0
  145. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/02.sql +0 -0
  146. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/03.sql +0 -0
  147. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/04.sql +0 -0
  148. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/05.sql +0 -0
  149. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/06.sql +0 -0
  150. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/07.sql +0 -0
  151. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/08.sql +0 -0
  152. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/09.sql +0 -0
  153. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/10.sql +0 -0
  154. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/11.sql +0 -0
  155. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/12.sql +0 -0
  156. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/13.sql +0 -0
  157. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/14.sql +0 -0
  158. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/15.sql +0 -0
  159. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/16.sql +0 -0
  160. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/17.sql +0 -0
  161. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/18.sql +0 -0
  162. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/19.sql +0 -0
  163. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/20.sql +0 -0
  164. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/21.sql +0 -0
  165. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/22.sql +0 -0
  166. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/23.sql +0 -0
  167. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/24.sql +0 -0
  168. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/25.sql +0 -0
  169. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/26.sql +0 -0
  170. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/27.sql +0 -0
  171. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/28.sql +0 -0
  172. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/expected/29.sql +0 -0
  173. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/01.sql +0 -0
  174. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/02.sql +0 -0
  175. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/03.sql +0 -0
  176. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/04.sql +0 -0
  177. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/05.sql +0 -0
  178. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/06.sql +0 -0
  179. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/07.sql +0 -0
  180. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/08.sql +0 -0
  181. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/09.sql +0 -0
  182. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/10.sql +0 -0
  183. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/11.sql +0 -0
  184. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/12.sql +0 -0
  185. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/13.sql +0 -0
  186. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/14.sql +0 -0
  187. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/15.sql +0 -0
  188. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/16.sql +0 -0
  189. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/17.sql +0 -0
  190. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/18.sql +0 -0
  191. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/19.sql +0 -0
  192. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/20.sql +0 -0
  193. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/21.sql +0 -0
  194. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/22.sql +0 -0
  195. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/23.sql +0 -0
  196. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/24.sql +0 -0
  197. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/25.sql +0 -0
  198. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/26.sql +0 -0
  199. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/27.sql +0 -0
  200. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/28.sql +0 -0
  201. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/fixtures/input/29.sql +0 -0
  202. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_align.py +0 -0
  203. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_align_off.py +0 -0
  204. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_align_targets.py +0 -0
  205. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_ast_equiv.py +0 -0
  206. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_atomic_writes.py +0 -0
  207. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_axis_matrix.py +0 -0
  208. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_benchmark_tool.py +0 -0
  209. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_blank_lines.py +0 -0
  210. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_bodylint.py +0 -0
  211. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_boolean_position.py +0 -0
  212. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_casing.py +0 -0
  213. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_clause_order.py +0 -0
  214. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_clauses.py +0 -0
  215. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_cli.py +0 -0
  216. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_comma_joins_lateral_udf.py +0 -0
  217. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_comma_position.py +0 -0
  218. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_comment_and_procedure_bugs.py +0 -0
  219. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_comment_safety.py +0 -0
  220. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_comments.py +0 -0
  221. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_comments_in_predicates.py +0 -0
  222. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_configfile.py +0 -0
  223. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_corpus.py +0 -0
  224. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_coverage_round_2.py +0 -0
  225. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_ddl.py +0 -0
  226. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_dialect_guard.py +0 -0
  227. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_distinct.py +0 -0
  228. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_dml.py +0 -0
  229. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_docs_examples.py +0 -0
  230. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_expr.py +0 -0
  231. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_file_selection.py +0 -0
  232. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_fromjoin.py +0 -0
  233. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_golden.py +0 -0
  234. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_gui.py +0 -0
  235. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_init_config.py +0 -0
  236. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_keyword_case.py +0 -0
  237. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_knob_combinations.py +0 -0
  238. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_line_endings.py +0 -0
  239. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_negated_is_null.py +0 -0
  240. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_nested_constructs.py +0 -0
  241. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_no_silent_declines.py +0 -0
  242. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_on_placement.py +0 -0
  243. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_pivot.py +0 -0
  244. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_presets.py +0 -0
  245. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_quoted_column_aliases.py +0 -0
  246. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_remaining_constructs.py +0 -0
  247. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_report.py +0 -0
  248. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_report_growth_and_policy.py +0 -0
  249. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_river.py +0 -0
  250. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_robustness.py +0 -0
  251. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_safety.py +0 -0
  252. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_select_placement.py +0 -0
  253. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_skip.py +0 -0
  254. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_splitter.py +0 -0
  255. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_sqlfluff_coexistence.py +0 -0
  256. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_sqlfluff_gate.py +0 -0
  257. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_sqlglot_conformance.py +0 -0
  258. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_stdin_and_api.py +0 -0
  259. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_style_knobs.py +0 -0
  260. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_subquery.py +0 -0
  261. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_table_alias.py +0 -0
  262. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_table_names.py +0 -0
  263. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_templating.py +0 -0
  264. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_trailing_punctuation.py +0 -0
  265. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_unaliased_tables.py +0 -0
  266. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_upstream_and_tail.py +0 -0
  267. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_values_and_joins.py +0 -0
  268. {sqlalign-1.1.0 → sqlalign-1.3.0}/tests/test_width_off_and_body_blanks.py +0 -0
  269. {sqlalign-1.1.0 → sqlalign-1.3.0}/tools/benchmark.py +0 -0
  270. {sqlalign-1.1.0 → sqlalign-1.3.0}/tools/build_docs.py +0 -0
  271. {sqlalign-1.1.0 → sqlalign-1.3.0}/tools/docs.css +0 -0
  272. {sqlalign-1.1.0 → sqlalign-1.3.0}/tools/docs.js +0 -0
  273. {sqlalign-1.1.0 → sqlalign-1.3.0}/tools/docs_settings.py +0 -0
  274. {sqlalign-1.1.0 → sqlalign-1.3.0}/tools/fetch_corpus.py +0 -0
  275. {sqlalign-1.1.0 → sqlalign-1.3.0}/tools/shots.py +0 -0
@@ -0,0 +1,481 @@
1
+ # Changelog
2
+
3
+ ## 1.3.0
4
+
5
+ The release is in two halves. The first is what sqlalign now does that it did
6
+ not: statements it used to pass through now format, and a selection can be
7
+ formatted on its own. The second is four things it was doing to your files that
8
+ it should not have been — all found by auditing rather than reported, all silent,
9
+ and all now either fixed or declined.
10
+
11
+ ### Statements sqlglot cannot print as written now format anyway
12
+
13
+ 1.2 stopped sqlalign respelling statements, by passing them through when the
14
+ render would have changed a spelling. Honest, and it meant `ALTER COLUMN x TYPE
15
+ text`, `DROP FUNCTION f()`, `ADD COLUMN c integer array` and `SET search_path TO
16
+ public` did not format at all.
17
+
18
+ They now format the one way that cannot lose a spelling: from the source text,
19
+ changing nothing but the case of the keywords. Nothing is rebuilt, so nothing
20
+ can be respelt.
21
+
22
+ Telling a keyword from an identifier is the whole of it, and neither obvious
23
+ answer works -- the tokenizer types `add`, `to` and `local` as ordinary words in
24
+ exactly these statements, and the keyword table says `year`, `name` and `value`
25
+ are keywords, so it would rename your columns. The parse tree separates them:
26
+ what you wrote as a name or a value is a node in it, and the grammar around it
27
+ lives in sqlglot's generator, on no node at all. A word you used both ways keeps
28
+ the case you gave it.
29
+
30
+ `SET ROLE reporting` and its relatives still pass through. sqlglot cannot parse
31
+ them, so there is no tree to ask, and every word in one would read as grammar --
32
+ which would rename the role.
33
+
34
+ ### `--lines`: format a selection
35
+
36
+ ```console
37
+ $ sqlalign --lines 40:58 models/orders.sql # just those lines
38
+ $ sqlalign --lines 12 --lines 40:58 orders.sql # two selections
39
+ $ sqlalign --diff --lines 40:58 orders.sql # review before writing
40
+ ```
41
+
42
+ The unit is the statement, not the line: half a statement does not parse, so a
43
+ range starting or ending inside one formats it entire. Everything outside comes
44
+ back byte-identical, blank lines included -- asking about line 12 is not asking
45
+ for the spacing at line 40 to be normalised.
46
+
47
+ This is for adopting sqlalign on a repository nobody wants to reformat in one
48
+ commit: format the lines your change touches, and the review stays about your
49
+ change. An editor that hands over the selected text rather than line numbers --
50
+ a visual selection piped through `:!` in vim -- wants `sqlalign -` instead.
51
+
52
+ ### `--sqlfluff-config`
53
+
54
+ sqlalign --lint --sqlfluff-config ~/company/.sqlfluff models/
55
+
56
+ Points `--lint` at a config outside the repository, which is the shape a shared
57
+ company ruleset actually has: one file, many checkouts, no copy per repo. Without
58
+ it, `--lint` discovers a config by walking up from the file and falls back to a
59
+ generated one. `--lint` reports; it has never called `sqlfluff fix`.
60
+
61
+ ### A comment on its own line no longer costs you the whole procedure
62
+
63
+ An own-line comment inside a `$$` body sent the entire procedure through
64
+ unformatted. The clause splitter glues such a comment to the statement below it,
65
+ so the plain-clause renderer saw a comment with code after it -- which has no
66
+ faithful one-line rendering -- and declined. A procedure that reads
67
+
68
+ begin
69
+ -- clear the staging table
70
+ delete from staging;
71
+
72
+ is the ordinary way people write plpgsql, and this made it unformattable.
73
+
74
+ It is faithfully renderable, just not on one line. The comment now stays on its
75
+ own line above the code, exactly as written. The same merged comment was also
76
+ hiding the keyword the body parser dispatches on, so an `IF` behind a comment
77
+ was neither recognised as a block nor found as the `END`, and the procedure
78
+ declined a second time as malformed.
79
+
80
+ What still declines is the one shape with no faithful rendering: a comment with
81
+ code after it on the same line.
82
+
83
+ ### Declines are named in SQL rather than in Python
84
+
85
+ `SET ROLE reporting` and `RESET ROLE` reported as `unsupported construct
86
+ (Command)`. `Command` is sqlglot's catch-all for syntax its parser does not
87
+ model, so it named the fallback rather than the statement, and named every
88
+ unrelated construct that lands there the same way. `SET search_path TO public`
89
+ had the milder version: `Set`, a class name where SQL was meant.
90
+
91
+ They are now named for the keyword the statement starts with, checked against
92
+ the dialect's own vocabulary. sqlglot's accompanying log line -- `'SET ROLE
93
+ reporting' contains unsupported syntax. Falling back to parsing as a
94
+ 'Command'.` -- no longer reaches the CLI's stderr, since sqlalign reports the
95
+ same statement by name and with the text it passed through. The library leaves
96
+ that logger alone.
97
+
98
+ ### Corrections
99
+
100
+ Each of these changed a file without saying so.
101
+
102
+ **If you ran 1.2 or earlier over procedures or intervals, your files may already
103
+ carry these changes.** Measured against 1.2.0 rather than described from memory:
104
+
105
+ | What 1.2 and earlier did | Still valid SQL | Meaning changed |
106
+ |---|---|---|
107
+ | `interval '14 days'` came back as `INTERVAL '14 DAYS'` | yes | no — interval units are case-insensitive |
108
+ | `LANGUAGE 'plpgsql'` came back as `LANGUAGE plpgsql` | yes | no |
109
+ | `$BODY$` came back as `$body$`, under `keyword_case = "lower"` only | yes | no — both ends moved together |
110
+ | `DECLARE n int; -- note` came back with the comment keyword-cased and a `;` inside it | yes | no — comment text only |
111
+ | A `LANGUAGE sql` body's last statement lost its terminator into a trailing comment | yes | no — a final statement needs none |
112
+ | **`$café$ … $café$` had its CONTENTS reformatted** | yes | **yes — the string literal changed** |
113
+
114
+ Only the last one altered anything a query would return, and only if you use a
115
+ dollar-quote tag containing non-ASCII characters, which is legal and rare. The
116
+ rest are byte differences in valid SQL that means what it meant.
117
+
118
+ To find the last one, look for a non-ASCII dollar tag:
119
+
120
+ ```console
121
+ $ grep -rlP '\$[^\x00-\x7F$]+\$' --include='*.sql' .
122
+ ```
123
+
124
+ For the rest, your version control already has the answer — the diff from the
125
+ commit where sqlalign first ran over a file is the complete list of what it
126
+ changed, and none of it needs undoing.
127
+
128
+ ### The token guard was blind to case inside a string literal
129
+
130
+ 1.2 added a token census so a statement sqlglot's parser silently respells is
131
+ passed through instead. It uppercased every token before counting, string
132
+ literals included -- so a change inside one was invisible to it, and to the other
133
+ two checks as well: `INTERVAL '14 days'` parses to `Var(DAYS)`, identical tree
134
+ either way, so `ast_equal` could not see it and neither could the census.
135
+
136
+ `INTERVAL '14 days'` had been going out as `INTERVAL '14 DAYS'` in every release
137
+ up to and including 1.2, with nothing declining. Literal content is now compared
138
+ as written.
139
+
140
+ Closing that alone would have stopped `interval '14 days'` formatting at all,
141
+ since the spelling is gone from the tree by the time the renderer runs. It is
142
+ restored from the statement's own source instead, so the common case formats and
143
+ keeps what the author typed. Case only, looked up in the statement being
144
+ rendered -- a substitution cannot introduce a spelling the author did not write,
145
+ and if one somehow did, the census now sees it. A statement that writes the same
146
+ literal two ways offers neither spelling, since either choice would respell the
147
+ other, and a `$$` body is exempt from the census that would otherwise catch it.
148
+
149
+ ### The rewrite guard now reaches inside a procedure body
150
+
151
+ 1.2's census could not run on a statement carrying a `$$` body. The tokenizer
152
+ sees a body as one token, so comparing the whole statement sees nothing inside
153
+ it, and comparing the body's own tokens compares a laid-out body against an
154
+ unformatted one. So bodies were excluded, and a respelling inside a procedure
155
+ had nothing catching it -- which is how `INTERVAL '14 days'` shipped as
156
+ `'14 DAYS'` from inside one.
157
+
158
+ Each clause is now compared against the clause it was rendered from, using the
159
+ split the structural check already relies on. Three things had to change first,
160
+ and the third is a behaviour change worth naming: **`LANGUAGE 'plpgsql'` keeps
161
+ its quoting.** It was being normalised to the bare form, which is a respelling,
162
+ and this was the last place the engine still performed one on your behalf.
163
+
164
+ A procedure that respells is passed through rather than cased from source: one
165
+ clause would cost every other clause in the body its layout.
166
+
167
+ ### Three fixes around dollar-quoted bodies
168
+
169
+ Tagged dollar quotes (`$func$` rather than bare `$$`) were already a working
170
+ case, and auditing that path found three defects — two of which had nothing to
171
+ do with tags.
172
+
173
+ **A non-ASCII tag changed your data.** Postgres says a dollar-quote tag follows
174
+ the rules for an unquoted identifier, and those are not ASCII-only: `$café$` and
175
+ `$ñ$` are legal. sqlalign's pattern was ASCII-only, so it did not see the region
176
+ as a quoted one at all — the file was cut at a `;` *inside* the literal and the
177
+ fragments formatted as SQL. A `<>` inside a `$ñ$ … $ñ$` string came back as `!=`,
178
+ with the warnings still reporting "passthrough". The pattern now follows
179
+ Postgres, and it has one definition rather than the two that had to be found and
180
+ widened separately.
181
+
182
+ **`keyword_case = "lower"` lowered the tag itself.** `$BODY$` shipped as
183
+ `$body$` at both ends, silently: valid SQL, which is why nothing objected, but
184
+ not what you wrote. Neither safety layer could see it — sqlglot's `Heredoc` does
185
+ not record the tag and the census excludes it. The `dbt` preset sets that case,
186
+ so it reached everyone using it.
187
+
188
+ **A comment inside a body was outside the comment guard.** `comment_text`
189
+ returned `[]` for an entire procedure, because a body is one token and it did not
190
+ descend. `comments_equal` was therefore vacuously true for anything in one, and
191
+ `DECLARE n int; -- count from the source table` shipped as
192
+ `-- count FROM the source TABLE;` — keyword-cased, with the terminator inside the
193
+ comment. Both the guard and `_render_declare` are fixed; this one affected bare
194
+ `$$` too.
195
+
196
+ Putting the guard in place immediately caught a second instance on the other
197
+ rendering path: `_render_sql_stmt` appended the terminator to the raw clause, so
198
+ a `LANGUAGE sql` body reading `select 1 -- why` shipped as `SELECT 1 -- why;`
199
+ with the statement left unterminated. Also fixed.
200
+
201
+ ### Fixed
202
+
203
+ - **`REVOKE` declined while the `GRANT` above it formatted.** Not a modelling
204
+ gap -- REVOKE parses to its own node and renders on one line exactly as GRANT
205
+ does. It was missing from the layout dispatch, and a permissions script is
206
+ where the asymmetry shows.
207
+
208
+ ## 1.2.0
209
+
210
+ ### sqlalign no longer respells your statements silently
211
+
212
+ The safety net compares output against input as a syntax tree, under the same
213
+ sqlglot. That is blind to a rewrite sqlglot's own parser performs: two spellings
214
+ collapse to one node, so printing either compares equal. Twenty statements went
215
+ through changed, with no decline and no warning -- `ADD COLUMN c INTEGER ARRAY`
216
+ came back as `INT`, `DROP FUNCTION f()` lost the signature that names the
217
+ overload, `WITH CSV HEADER FORCE QUOTE a, b` became three options where the
218
+ author wrote one, and T-SQL `SET (LOCK_ESCALATION = AUTO)` gained an invented
219
+ `WITH (...)` that SQL Server does not accept.
220
+
221
+ Each statement's tokens are now counted either side of formatting, and one that
222
+ gained or lost a token is passed through byte-identical instead. Nothing here is
223
+ a hand-kept list of allowed differences: type synonyms are derived by asking
224
+ sqlglot which spellings parse to the same node, so a new dialect or a renamed
225
+ type is followed rather than disagreed with, and the three settings that choose
226
+ a spelling are normalised away because choosing is their job.
227
+
228
+ Order is deliberately not compared. The tree already catches anything that
229
+ moved, so the two checks divide the space -- and comparing order here would
230
+ decline `GROUP BY ROLLUP(a, b), c` printed as `GROUP BY c, ROLLUP(a, b)`, which
231
+ is the same grouping sets.
232
+
233
+ ### Fixed
234
+
235
+ - **T-SQL paging emitted invalid SQL.** `OFFSET 10 ROWS` came back as
236
+ `OFFSET 10`, which SQL Server rejects. `Offset` records only the number, so
237
+ the AST check could not tell the spellings apart; the keyword is now emitted
238
+ where the dialect requires it, asked of sqlglot rather than hardcoded.
239
+
240
+ ### `dialect` is a config key
241
+
242
+ ```toml
243
+ # redshift-warehouse/.sqlalign.toml
244
+ dialect = "redshift"
245
+ ```
246
+
247
+ Resolved per file from the config nearest it, so one command -- one editor
248
+ action, one pre-commit hook -- can span a Postgres repository and a Redshift one
249
+ and be right in both. `--dialect` still overrides for a one-off run.
250
+
251
+ This is not the auto-detection sqlalign refuses to do. Sniffing a file cannot be
252
+ covered by the safety guarantee; declaring the engine in a file your team
253
+ reviews is the opposite of a guess, and more explicit than a flag typed into an
254
+ editor's tool settings and never looked at again.
255
+
256
+ ### Fixed
257
+
258
+ - `CREATE OR ALTER VIEW` came back as `CREATE OR REPLACE VIEW` under T-SQL --
259
+ Postgres syntax written into a T-SQL file, which the AST check could not
260
+ reject because both spellings parse to the same `replace` flag.
261
+
262
+ ## 1.1.0
263
+
264
+ ### The guarantee now covers comments
265
+
266
+ Every statement was already re-parsed and compared as a syntax tree. Comments are
267
+ not in that tree — sqlglot hangs them off tokens — so the check passed whether or
268
+ not a comment survived, and the two worst bugs in this project's history lived in
269
+ that gap and were semantic rather than cosmetic: `SELECT a -- c,` lost a
270
+ separator, and `SELECT a -- note;` left the statement unterminated so it swallowed
271
+ the next one.
272
+
273
+ Each statement is now also compared on the comments it carries, and one that
274
+ would differ is passed through byte-identical like any other. Text and order are
275
+ compared, not position: the layout deliberately moves a comment to the end of the
276
+ row above. Comments inside a `$$` body remain outside this check; those
277
+ statements are compared structurally instead.
278
+
279
+ ### Running it where you already work
280
+
281
+ - **pre-commit hooks and a GitHub Action.** `sqlalign` rewrites and fails so you
282
+ restage; `sqlalign-check` only reports. The action defaults to `--check`,
283
+ because an action that silently reformats a checkout is not what a gate is for.
284
+ - **`sqlalign -`** reads stdin and writes stdout, which is what an editor's
285
+ format-on-save runs. `--check` and `--diff` still report rather than write.
286
+ - **A Python API.** `sqlalign.format` returns the text; `sqlalign.format_result`
287
+ also returns what happened. Both exist because a statement sqlalign cannot
288
+ model comes back byte-identical rather than raising, so the simple function
289
+ cannot tell "formatted" from "left alone".
290
+ - **`sqlalign --init`** writes a starter `.sqlalign.toml`, every setting
291
+ commented out. A starter that pinned eighteen settings would freeze you on the
292
+ day's defaults and call it a decision.
293
+
294
+ ### Wider support
295
+
296
+ - **Python 3.10 and 3.11.** Nothing in the engine needed porting; `tomllib` gets
297
+ a shim below 3.11. CI runs all four versions, and a test compares the
298
+ classifiers, the `requires-python` floor and the CI matrix against each other.
299
+ - **sqlglot `>=30.14,<31`** rather than a single patch line. The range is safe
300
+ because `tests/test_sqlglot_conformance.py` asserts each AST shape the layout
301
+ reads, and CI runs the whole suite against the newest release the range allows.
302
+ The safety net cannot catch an upstream shape change on its own: it compares
303
+ output to input under the same sqlglot, so both sides move together.
304
+
305
+ ### Fixed
306
+
307
+ - **Comments inside a `$$` body were keyword-cased, with the terminator spliced
308
+ into the comment.** `-- log it for the user` shipped as
309
+ `-- LOG it FOR the user;` with no decline. A same-line trailing comment is now
310
+ reproduced verbatim; a comment position the body renderer does not model
311
+ declines instead of guessing — the same contract the SQL comment engine
312
+ follows, now held on both sides of the dollar quotes.
313
+ - **`--report` and `--max-declines` were blind to templated files.** The
314
+ Jinja/dbt path dropped the statement and decline counts, so most of a dbt
315
+ project was invisible to the coverage gate.
316
+ - **A quoted identifier immunised the keyword it was spelled as.**
317
+ `SELECT a AS "FROM"` under `keyword_case = "lower"` left the real `FROM`
318
+ upper in an otherwise lowercase file.
319
+ - **`sqlalign - | head` dumped a traceback.** The command now exits `141`, the
320
+ shell's spelling of death-by-SIGPIPE.
321
+ - `WITH "cte" AS (...)` declined. The CTE name printed from `.alias`, which
322
+ strips quoting, so the output named a different relation. Machine-generated SQL
323
+ quotes every identifier, so this affected a whole class of input.
324
+ - `WHERE NOT b IS NULL` declined under Postgres. The renderer rewrote it to
325
+ `b IS NOT NULL` — the same meaning, but not what was written. Whether the two
326
+ spellings can be told apart is a property of the dialect, so it is now probed
327
+ rather than assumed.
328
+
329
+ Both were found by a new corpus suite that runs the formatter over third-party
330
+ SQL — sqlglot's own fixtures, dbt's example project, and a macro-heavy dbt
331
+ package — vendored at pinned commits.
332
+
333
+ ### Also
334
+
335
+ - `--report` names the construct declining most often and links a pre-filled
336
+ issue, so a coverage gap measured on your SQL has somewhere to go.
337
+ - The settings panel says why a control is greyed out, and the config it writes
338
+ records where it came from.
339
+ - A published benchmark (`tools/benchmark.py`): about 180 files/s, which is why
340
+ there is no `--jobs` flag.
341
+ - The style stability policy is written down: no style change in a patch release,
342
+ enforced by byte-exact goldens in their own CI job.
343
+
344
+ ## 1.0.2
345
+
346
+ ### Fixed
347
+
348
+ **An interrupted run could truncate the file it was formatting.** Writing with
349
+ `open(path, "w")` empties the file before the replacement is written, so a run
350
+ stopped part way through -- Ctrl-C over a large repository, a full disk, a
351
+ killed process -- left some file holding a prefix of its formatted self, with
352
+ the original gone. Files are now written to a neighbour and renamed into place,
353
+ so what is on disk is either the whole old file or the whole new one. Symlinks
354
+ are written through rather than replaced, and permissions are carried across.
355
+
356
+ **A file that was not UTF-8 raised a traceback and aborted the run.** The read
357
+ is UTF-8, and a `UnicodeDecodeError` is not an `OSError`, so it escaped the
358
+ per-file handler and took the whole invocation with it — every file after the
359
+ first undecodable one was silently never formatted. Such a file is now reported
360
+ and left exactly as it is: guessing an encoding would mean writing it back in a
361
+ different one, which is the kind of change sqlalign exists not to make.
362
+
363
+ **An unwritable file raised a traceback and aborted the run.** A read-only file
364
+ now reports `sqlalign: [Errno 13] Permission denied: <path>`, exits `2`, and
365
+ leaves the remaining files to process -- which is what the exit-code table
366
+ already documented.
367
+
368
+ `py.typed` was missing, so every type checker skipped the package while the
369
+ `Typing :: Typed` classifier said the opposite. sqlalign is annotated and
370
+ `format_sql` is importable; both now work as advertised.
371
+
372
+ `--gui`'s missing-tkinter message went to stdout rather than stderr.
373
+
374
+ `--lint` no longer warns about a sqlfluff patch release. The coexistence config
375
+ is checked against a known sqlfluff, and any difference warned; sqlfluff 4.3.0
376
+ then shipped, so every run printed a note about a release that had moved nothing
377
+ sqlalign uses. The check now compares the series, and is silent for a sqlfluff
378
+ older than the checked one -- the floor on the `lint` extra bounds that, and CI
379
+ now runs the coexistence tests against it. The mappings are verified against
380
+ sqlfluff 4.3.0.
381
+
382
+ ### Documentation
383
+
384
+ `--report` and `--max-declines` add output without changing the mode, so on
385
+ their own they rewrite the files they counted. The dialects guide told you to
386
+ run `sqlalign --report` over your own SQL to see what declined, which would have
387
+ reformatted the repository you were surveying. Both the guide and the flag's
388
+ help now say to pair it with `--check`.
389
+
390
+ Install instructions said `uv tool install .`, which installs from a clone. That
391
+ was the only option before the package was published; it is now
392
+ `pip install sqlalign`. The CI example in the guide told you to run that same
393
+ command inside your own repository, where it would have tried to install your
394
+ SQL repo as a Python package.
395
+
396
+ Also corrected: `--preset` documented four of its six values (`gitlab` and
397
+ `river` were missing), three places still said the project had no CI, and the
398
+ README linked the settings reference as a raw HTML file rather than to the
399
+ published site. Documented choice lists are now checked against the argument
400
+ parser by a test.
401
+
402
+ ## 1.0.1
403
+
404
+ No functional change. `1.0.0` was tagged before the package was ever published,
405
+ so this is the first version to reach an index.
406
+
407
+ ## 1.0.0
408
+
409
+ First release.
410
+
411
+ sqlalign formats SQL into a columnar, aligned house style, and re-parses every
412
+ statement it writes to prove it did not change what the SQL means.
413
+
414
+ ### The guarantee
415
+
416
+ Every statement is re-parsed after formatting and compared against the input as
417
+ a syntax tree. If the output would differ semantically — or if the engine does
418
+ not fully model the construct — that statement is passed through byte-identical
419
+ with a warning instead, and the run still exits `0`.
420
+
421
+ A passthrough is not a failure. It is what makes the tool safe to run across a
422
+ repository you did not write.
423
+
424
+ ### Formatting
425
+
426
+ - **Postgres, Redshift and SQL Server**, selected with `--dialect`. Adding a
427
+ dialect requires auditing every keyword the layout emits, because the AST
428
+ check cannot catch output that is valid SQL but invalid for the target
429
+ engine — so the list is short and deliberate.
430
+ - **plpgsql `$$` bodies are formatted**, statement by statement, rather than
431
+ treated as an opaque string.
432
+ - **Jinja and dbt templating** is masked before parsing, so a templated model
433
+ formats instead of failing to parse.
434
+ - Comments are reproduced faithfully or the statement declines — never moved,
435
+ never restyled.
436
+
437
+ ### Configuration
438
+
439
+ - `.sqlalign.toml`, with CLI flags overriding it for a single run.
440
+ - **18 style options**, each documented with the same SQL rendered under each of
441
+ its values.
442
+ - **Six presets**: `house`, `compact`, `trailing`, `dbt`, `gitlab`, `river`. The
443
+ last two reproduce their source style guides byte for byte and are pinned to
444
+ those documents by tests.
445
+ - Alignment is one mechanism with a list of targets, so a team can keep the
446
+ join-condition column and drop the rest — or turn padding off entirely with
447
+ `--no-align` and keep the line structure, which is what most published style
448
+ guides ask for.
449
+
450
+ ### Running it
451
+
452
+ - Files or directories, with `--exclude` globs.
453
+ - `--check` for CI, `--diff` to preview, `--stdout` to pipe.
454
+ - `--report` counts what declined and ranks the causes, so a passthrough stops
455
+ being invisible; `--max-declines N` turns that into a gate.
456
+ - `--gui` opens a settings panel with a live preview. **Experimental** — the
457
+ CLI and config file are the supported surface.
458
+
459
+ ### Alongside sqlfluff
460
+
461
+ - `--print-sqlfluff-config` generates a config that stops the two tools
462
+ fighting: sqlalign owns layout, so the whole `layout` rule group is excluded
463
+ by name, and every semantic rule stays on.
464
+ - `--lint` runs sqlfluff over the formatted result in the same command.
465
+ - **`--lint` reads inside `$$` bodies, which sqlfluff cannot.** To its parser a
466
+ plpgsql body is a single string literal, so nothing inside one is ever linted.
467
+ sqlalign already locates those statements in order to format them, and hands
468
+ them over with their real line and column numbers.
469
+
470
+ ### Known limits
471
+
472
+ These decline rather than guess, and say why:
473
+
474
+ - `PIVOT`/`UNPIVOT` under Postgres, which has no such syntax.
475
+ - T-SQL `IF`/`WHILE` inside a procedure body: sqlglot leaves part of the body
476
+ unparsed, including the whole `ELSE` branch, so laying out the tree would drop
477
+ it silently.
478
+ - A comment buried inside an expression, or in a positional `GROUP BY 1, 2` —
479
+ neither has a row of its own to sit on.
480
+ - Constructs sqlglot cannot parse or cannot round-trip through its own
481
+ generator. `--report` names each one.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sqlalign
3
- Version: 1.1.0
3
+ Version: 1.3.0
4
4
  Summary: A SQL formatter that cannot change what your SQL means
5
5
  Project-URL: Homepage, https://sqlalign.lumaru.app/
6
6
  Project-URL: Documentation, https://sqlalign.lumaru.app/v1/
@@ -370,11 +370,14 @@ would otherwise mean a team believes it has a setting it doesn't have.
370
370
  | `--isolated` | off | ignore any config file |
371
371
  | `--print-sqlfluff-config` | — | print a `.sqlfluff` that lets sqlfluff run alongside sqlalign, and exit |
372
372
  | `--lint` | off | after formatting, run sqlfluff over the result (needs `pip install 'sqlalign[lint]'`) |
373
+ | `--sqlfluff-config PATH` | discovered | point `--lint` at a config outside the repository — one shared ruleset, many checkouts |
374
+ | `--lines START:END` | off | format only statements overlapping these 1-based, inclusive lines; the rest of the file stays byte-identical. Repeatable; one file or `-` |
373
375
  | `--body-blank-lines N` | `1` | blank lines between the elements of a `$$` body |
374
376
  | `--gui` | — | *(experimental)* open a settings panel with a live preview, and exit |
375
377
  | `--report` | off | print a coverage summary: how many statements formatted, and what the rest declined on. Adds output without changing the mode — pair with `--check` to survey without writing |
376
378
  | `--max-declines N` | — | exit 1 if more than N statements pass through unformatted (implies `--report`) |
377
379
  | `--show-config` | off | print effective settings as TOML and exit |
380
+ | `--init` | — | write a starter `.sqlalign.toml` beside the file and exit |
378
381
  | `--no-strict-config` | off | warn on unknown config keys instead of failing |
379
382
 
380
383
  `--neq-style` and `--decimal-style` exist because sqlglot's parser collapses each
@@ -338,11 +338,14 @@ would otherwise mean a team believes it has a setting it doesn't have.
338
338
  | `--isolated` | off | ignore any config file |
339
339
  | `--print-sqlfluff-config` | — | print a `.sqlfluff` that lets sqlfluff run alongside sqlalign, and exit |
340
340
  | `--lint` | off | after formatting, run sqlfluff over the result (needs `pip install 'sqlalign[lint]'`) |
341
+ | `--sqlfluff-config PATH` | discovered | point `--lint` at a config outside the repository — one shared ruleset, many checkouts |
342
+ | `--lines START:END` | off | format only statements overlapping these 1-based, inclusive lines; the rest of the file stays byte-identical. Repeatable; one file or `-` |
341
343
  | `--body-blank-lines N` | `1` | blank lines between the elements of a `$$` body |
342
344
  | `--gui` | — | *(experimental)* open a settings panel with a live preview, and exit |
343
345
  | `--report` | off | print a coverage summary: how many statements formatted, and what the rest declined on. Adds output without changing the mode — pair with `--check` to survey without writing |
344
346
  | `--max-declines N` | — | exit 1 if more than N statements pass through unformatted (implies `--report`) |
345
347
  | `--show-config` | off | print effective settings as TOML and exit |
348
+ | `--init` | — | write a starter `.sqlalign.toml` beside the file and exit |
346
349
  | `--no-strict-config` | off | warn on unknown config keys instead of failing |
347
350
 
348
351
  `--neq-style` and `--decimal-style` exist because sqlglot's parser collapses each
@@ -326,10 +326,39 @@ warning, so an expected decline is distinguishable from a bug in stderr:
326
326
  |---|---|
327
327
  | sqlglot cannot parse the statement | `passthrough (parse error line N): …` |
328
328
  | a layout handler raised `Unsupported` | `unsupported construct, passed through: …` |
329
+ | the render would respell the statement, and casing it from source is not possible either | `formatting would respell this statement, passed through unformatted: …` — the first half is usually recoverable (see below); this is what is left |
329
330
  | the output would not AST-compare equal | `formatting would change semantics, passed through unformatted: …` — **a bug report**, not a decline: the renderer emitted something that means a different thing |
330
331
  | …and sqlglot cannot round-trip the input either | `sqlglot cannot round-trip this statement, passed through unformatted: …` — the fault is upstream, so no formatter built on sqlglot could satisfy the check |
331
332
  | any other exception | `internal formatter error, passed through (please report): …` |
332
333
 
334
+ **A respelling is usually recovered rather than declined.** sqlglot's parser
335
+ collapses some pairs of spellings onto one node — `ALTER COLUMN x TYPE t` and
336
+ `SET DATA TYPE t` are the same tree — so rendering from the node prints whichever
337
+ the generator prefers. When the token census catches that, the statement is cased
338
+ from its own source instead (`sourcecase.py`): the source text with keyword spans
339
+ recased and every other byte untouched. Nothing is rebuilt, so nothing can be
340
+ respelt, and the same three checks are re-run against the result.
341
+
342
+ Keywords are told from identifiers by the parse tree, not by the keyword table.
343
+ What the author wrote as a name or value is a node; the grammar around it lives
344
+ in the generator and is on no node. A statement sqlglot could only parse as
345
+ `exp.Command` has no such tree and still passes through.
346
+
347
+ The construct in an `unsupported construct (…)` warning is the node type the
348
+ layout engine declined to model. One node type needs translating: `exp.Command`
349
+ is sqlglot's catch-all for syntax its parser does not model at all, so it is the
350
+ same word for every unrelated statement that lands there. It is reported under
351
+ the keyword sqlglot kept on the node instead — `unsupported construct (SET)`
352
+ rather than `unsupported construct (Command)`.
353
+
354
+ sqlglot logs its own fallback for those statements (`'SET ROLE reporting'
355
+ contains unsupported syntax. Falling back to parsing as a 'Command'.`). The CLI
356
+ raises that logger to `ERROR`, because sqlalign reports the same statement by
357
+ name and with the text it passed through — the warning is a second, less
358
+ informative copy on the same stream. The library does not touch the logger:
359
+ `sqlalign.format` runs inside someone else's program, where silencing a
360
+ dependency is not a formatter's business.
361
+
333
362
  One decline is file-wide rather than per statement: a template expression too
334
363
  short to hold a same-width placeholder (`{{x}}`) fails before splitting, so the
335
364
  whole file passes through with `templating not maskable, passed through: …`. It
@@ -41,6 +41,7 @@ flags change that.
41
41
  | `--check` | off | Write nothing. Print `would reformat <path>` for each file that is not already formatted. Exit `1` if any is. |
42
42
  | `--stdout` | off | Write the formatted result to stdout instead of rewriting the file. Exit `0`. |
43
43
  | `--diff` | off | Write nothing. Print a unified diff of what would change. Exit `1` if anything would. |
44
+ | `--lines START:END` | off | Format only statements overlapping these 1-based, inclusive lines; the rest of the file comes back byte-identical. Repeatable. A bare `--lines 12` is that one line. Applies to a single file or `-`. |
44
45
  | `--line-ending {auto,lf,crlf}` | `auto` | Line endings to write. `auto` preserves each file's own — a CRLF file stays CRLF, and an already-formatted CRLF file does not report a spurious diff. |
45
46
 
46
47
  **`--check`, `--stdout` and `--diff` are mutually exclusive.** Passing two is an
@@ -117,11 +118,34 @@ else is an error unless you pass `--no-strict-config`.
117
118
 
118
119
  `align` · `align_targets` · `blank_lines_between_statements` ·
119
120
  `boolean_operator_position` · `clause_keyword_align` · `comma_position` ·
120
- `decimal_style` · `exclude` · `format_dollar_bodies` · `keyword_case` ·
121
+ `decimal_style` · `dialect` · `exclude` · `format_dollar_bodies` · `keyword_case` ·
121
122
  `neq_style` · `on_placement` · `preset` · `protect_templating` · `river_gutter` ·
122
123
  `select_indent` · `select_placement` · `table_alias_style` · `width`
123
124
 
124
- `--dialect` and `--line-ending` are the only settings with no config key. Three
125
+ ## Formatting a selection
126
+
127
+ ```console
128
+ $ sqlalign --lines 40:58 models/orders.sql # just those lines
129
+ $ sqlalign --lines 12 --lines 40:58 orders.sql # two selections
130
+ $ sqlalign --diff --lines 40:58 orders.sql # review before writing
131
+ ```
132
+
133
+ **The unit is the statement, not the line.** Half a statement does not parse, so
134
+ a range starting or ending inside one formats that statement entire — which is
135
+ also what a dragged editor selection means. A range that covers only blank lines
136
+ selects nothing and the file is left alone.
137
+
138
+ Everything outside the range is byte-identical, including the blank lines around
139
+ it. Asking for line 12 is not asking for the spacing at line 40 to be
140
+ normalised.
141
+
142
+ The use this exists for is adopting sqlalign on a repository nobody wants to
143
+ reformat in one commit: format the lines your change touches, leave the rest,
144
+ and the review stays about your change. For an editor filter that hands over
145
+ just the selected text — a visual selection piped through `:!` in vim — use
146
+ stdin instead: `sqlalign -` formats what it is given and needs no line numbers.
147
+
148
+ `--line-ending` is the only setting with no config key. Three
125
149
  of the four `--no-*` flags map onto the positive keys: `--no-align` is
126
150
  `align = false`, `--no-protect-templating` is `protect_templating = false`, and
127
151
  `--no-format-bodies` is `format_dollar_bodies = false`. The fourth,
@@ -128,9 +128,11 @@ error (see [Unknown keys](#unknown-keys-are-an-error)).
128
128
  | `keyword_case` | `"upper"` \| `"lower"` | `"upper"` | Case for keywords, function names and type names. Your identifiers and string literals are never touched. |
129
129
  | `neq_style` | `"!="` \| `"<>"` | `"!="` | Spelling for the not-equal operator. |
130
130
  | `decimal_style` | `"NUMERIC"` \| `"DECIMAL"` | `"NUMERIC"` | Spelling for the `NUMERIC`/`DECIMAL` type. |
131
+ | `body_blank_lines` | integer | `1` | Blank lines between the elements of a dollar-quoted body (`DECLARE`, `BEGIN`, each statement, `END`). Separate from `blank_lines_between_statements`, which never reaches inside a body. `0` packs the body tight. |
131
132
  | `format_dollar_bodies` | boolean | `true` | Format inside dollar-quoted (`$$`) procedure and function bodies. `false` passes the whole `CREATE FUNCTION` through byte-identical. |
132
133
  | `protect_templating` | boolean | `true` | Mask Jinja/dbt template expressions (`{{ }}`, `{% %}`, `{# #}`) before formatting so a templated model can be formatted at all. |
133
134
  | `blank_lines_between_statements` | integer, or unset | unset | Force N blank lines between every pair of statements. Unset means the house rule: one blank line between two multi-line statements, none otherwise. |
135
+ | `dialect` | `"postgres"` \| `"redshift"` \| `"tsql"` | `postgres` | The engine the SQL will run on. Resolved per file from the config nearest it, so one command can span a Postgres tree and a Redshift one. `--dialect` overrides it. |
134
136
  | `exclude` | list of glob strings (a bare string is also accepted) | none | Skip matching files when a directory is expanded. Selects files, not style — see [Excluding files](#excluding-files). |
135
137
 
136
138
  `neq_style` and `decimal_style` exist because the parser collapses each of those
@@ -139,14 +141,8 @@ the only two places sqlalign picks for you.
139
141
 
140
142
  ### Not config keys
141
143
 
142
- `--dialect` and `--line-ending` are command-line only. Putting `dialect` in a
143
- config file is a hard error:
144
-
145
- ```
146
- sqlalign: /home/you/warehouse/sqlalign.toml: unknown setting(s) ['dialect']; valid: ['align', 'align_targets', ...]
147
- ```
148
-
149
- (the real message lists every valid key; elided here for width).
144
+ `--line-ending` is the only setting with no config key. `--dialect` has one —
145
+ see the `dialect` row above — and the flag overrides it for a one-off run.
150
146
 
151
147
  ### `width` is a target, not a limit
152
148
 
@@ -302,7 +298,7 @@ the exit code is `2`:
302
298
 
303
299
  ```
304
300
  $ sqlalign q.sql
305
- sqlalign: /home/you/warehouse/.sqlalign.toml: unknown setting(s) ['comma_postion']; valid: ['align', 'align_targets', 'blank_lines_between_statements', 'boolean_operator_position', 'comma_position', 'decimal_style', 'exclude', 'format_dollar_bodies', 'keyword_case', 'neq_style', 'on_placement', 'preset', 'protect_templating', 'width']
301
+ sqlalign: /home/you/warehouse/.sqlalign.toml: unknown setting(s) ['comma_postion']; valid: ['align', 'align_targets', 'blank_lines_between_statements', 'body_blank_lines', 'boolean_operator_position', 'clause_keyword_align', 'comma_position', 'decimal_style', 'dialect', 'exclude', 'format_dollar_bodies', 'keyword_case', 'neq_style', 'on_placement', 'preset', 'protect_templating', 'river_gutter', 'select_indent', 'select_placement', 'table_alias_style', 'width']
306
302
  ```
307
303
 
308
304
  This is deliberate, and it is the opposite of what most tools do. A typo in a