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