sqlalign 1.2.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 (274) hide show
  1. {sqlalign-1.2.0 → sqlalign-1.3.0}/CHANGELOG.md +205 -0
  2. {sqlalign-1.2.0 → sqlalign-1.3.0}/PKG-INFO +4 -1
  3. {sqlalign-1.2.0 → sqlalign-1.3.0}/README.md +3 -0
  4. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/guide/architecture.md +29 -0
  5. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/guide/cli.md +24 -0
  6. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/guide/configuration.md +5 -9
  7. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/guide/dialects.md +8 -14
  8. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/guide/getting-started.md +24 -1
  9. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/architecture.html +28 -1
  10. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/cli.html +25 -3
  11. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/configuration.html +16 -7
  12. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/dialects.html +9 -12
  13. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/faq.html +1 -1
  14. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/getting-started.html +19 -3
  15. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/index.html +1 -1
  16. sqlalign-1.3.0/docs/v1/search-index.json +1 -0
  17. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/settings.html +1 -1
  18. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/v1/style.html +1 -1
  19. {sqlalign-1.2.0 → sqlalign-1.3.0}/pyproject.toml +1 -1
  20. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/casing.py +70 -1
  21. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/cli.py +75 -2
  22. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/formatter.py +139 -19
  23. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/keywordcase.py +17 -2
  24. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/__init__.py +54 -3
  25. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/comments.py +5 -2
  26. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/ddl.py +8 -1
  27. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/lint.py +9 -2
  28. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/plpgsql.py +151 -18
  29. sqlalign-1.3.0/src/sqlalign/sourcecase.py +90 -0
  30. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/spelling.py +78 -5
  31. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/splitter.py +15 -1
  32. sqlalign-1.3.0/tests/test_body_census.py +116 -0
  33. sqlalign-1.3.0/tests/test_body_comments.py +110 -0
  34. sqlalign-1.3.0/tests/test_decline_naming.py +106 -0
  35. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_docs_site.py +68 -0
  36. sqlalign-1.3.0/tests/test_dollar_tags.py +203 -0
  37. sqlalign-1.3.0/tests/test_line_ranges.py +114 -0
  38. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_lint_flag.py +51 -0
  39. sqlalign-1.3.0/tests/test_literal_spelling.py +132 -0
  40. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_plpgsql.py +15 -2
  41. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_rewrite_guard.py +67 -3
  42. sqlalign-1.3.0/tests/test_source_casing.py +115 -0
  43. {sqlalign-1.2.0 → sqlalign-1.3.0}/uv.lock +1 -1
  44. sqlalign-1.2.0/docs/v1/search-index.json +0 -1
  45. sqlalign-1.2.0/tests/test_body_comments.py +0 -73
  46. {sqlalign-1.2.0 → sqlalign-1.3.0}/.github/workflows/ci.yml +0 -0
  47. {sqlalign-1.2.0 → sqlalign-1.3.0}/.github/workflows/release.yml +0 -0
  48. {sqlalign-1.2.0 → sqlalign-1.3.0}/.gitignore +0 -0
  49. {sqlalign-1.2.0 → sqlalign-1.3.0}/.pre-commit-hooks.yaml +0 -0
  50. {sqlalign-1.2.0 → sqlalign-1.3.0}/.sqlfluff +0 -0
  51. {sqlalign-1.2.0 → sqlalign-1.3.0}/CONTRIBUTING.md +0 -0
  52. {sqlalign-1.2.0 → sqlalign-1.3.0}/LICENSE +0 -0
  53. {sqlalign-1.2.0 → sqlalign-1.3.0}/action.yml +0 -0
  54. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/guide/README.md +0 -0
  55. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/guide/faq.md +0 -0
  56. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/guide/style.md +0 -0
  57. {sqlalign-1.2.0 → sqlalign-1.3.0}/docs/index.html +0 -0
  58. {sqlalign-1.2.0 → sqlalign-1.3.0}/samples/queries.sql +0 -0
  59. {sqlalign-1.2.0 → sqlalign-1.3.0}/scripts/build_fixtures.py +0 -0
  60. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/__init__.py +0 -0
  61. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/align.py +0 -0
  62. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/bodylint.py +0 -0
  63. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/commas.py +0 -0
  64. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/config.py +0 -0
  65. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/configfile.py +0 -0
  66. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/gui.py +0 -0
  67. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/ir.py +0 -0
  68. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/case.py +0 -0
  69. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/conditions.py +0 -0
  70. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/cte.py +0 -0
  71. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/dml.py +0 -0
  72. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/expr.py +0 -0
  73. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/fromjoin.py +0 -0
  74. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/grouporder.py +0 -0
  75. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/select.py +0 -0
  76. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/setop.py +0 -0
  77. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/subquery.py +0 -0
  78. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/layout/window.py +0 -0
  79. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/py.typed +0 -0
  80. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/sqlfluffconfig.py +0 -0
  81. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/style.py +0 -0
  82. {sqlalign-1.2.0 → sqlalign-1.3.0}/src/sqlalign/templating.py +0 -0
  83. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/conftest.py +0 -0
  84. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/README.md +0 -0
  85. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__math__log_natural.sql +0 -0
  86. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__math__median.sql +0 -0
  87. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__math__percentile_cont.sql +0 -0
  88. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__math__rand.sql +0 -0
  89. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__regex__regexp_instr.sql +0 -0
  90. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized___ignore_row_if_expression.sql +0 -0
  91. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized___truth_expression.sql +0 -0
  92. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized__equal_expression.sql +0 -0
  93. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized__expression_between.sql +0 -0
  94. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests___generalized__expression_is_true.sql +0 -0
  95. {sqlalign-1.2.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
  96. {sqlalign-1.2.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
  97. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_count_to_equal.sql +0 -0
  98. {sqlalign-1.2.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
  99. {sqlalign-1.2.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
  100. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_values_to_contain_set.sql +0 -0
  101. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_distinct_values_to_equal_set.sql +0 -0
  102. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_max_to_be_between.sql +0 -0
  103. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_mean_to_be_between.sql +0 -0
  104. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_median_to_be_between.sql +0 -0
  105. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_min_to_be_between.sql +0 -0
  106. {sqlalign-1.2.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
  107. {sqlalign-1.2.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
  108. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_quantile_values_to_be_between.sql +0 -0
  109. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_stdev_to_be_between.sql +0 -0
  110. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__aggregate_functions__expect_column_sum_to_be_between.sql +0 -0
  111. {sqlalign-1.2.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
  112. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_between.sql +0 -0
  113. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_decreasing.sql +0 -0
  114. {sqlalign-1.2.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
  115. {sqlalign-1.2.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
  116. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_increasing.sql +0 -0
  117. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_null.sql +0 -0
  118. {sqlalign-1.2.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
  119. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__column_values_basic__expect_column_values_to_be_unique.sql +0 -0
  120. {sqlalign-1.2.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
  121. {sqlalign-1.2.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
  122. {sqlalign-1.2.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
  123. {sqlalign-1.2.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
  124. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/dbt-expectations/macros__schema_tests__distributional__expect_column_values_to_be_within_n_stdevs.sql +0 -0
  125. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__customers.sql +0 -0
  126. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__orders.sql +0 -0
  127. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__staging__stg_customers.sql +0 -0
  128. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__staging__stg_orders.sql +0 -0
  129. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/jaffle-shop/models__staging__stg_payments.sql +0 -0
  130. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/sqlglot/tests__fixtures__identity.sql +0 -0
  131. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/sqlglot/tests__fixtures__optimizer__optimizer.sql +0 -0
  132. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/corpus/sqlglot/tests__fixtures__pretty.sql +0 -0
  133. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/docs/dbt.sql +0 -0
  134. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/docs/fromblock.sql +0 -0
  135. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/docs/hero.sql +0 -0
  136. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/docs/plpgsql.sql +0 -0
  137. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/01.sql +0 -0
  138. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/02.sql +0 -0
  139. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/03.sql +0 -0
  140. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/04.sql +0 -0
  141. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/05.sql +0 -0
  142. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/06.sql +0 -0
  143. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/07.sql +0 -0
  144. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/08.sql +0 -0
  145. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/09.sql +0 -0
  146. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/10.sql +0 -0
  147. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/11.sql +0 -0
  148. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/12.sql +0 -0
  149. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/13.sql +0 -0
  150. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/14.sql +0 -0
  151. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/15.sql +0 -0
  152. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/16.sql +0 -0
  153. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/17.sql +0 -0
  154. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/18.sql +0 -0
  155. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/19.sql +0 -0
  156. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/20.sql +0 -0
  157. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/21.sql +0 -0
  158. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/22.sql +0 -0
  159. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/23.sql +0 -0
  160. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/24.sql +0 -0
  161. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/25.sql +0 -0
  162. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/26.sql +0 -0
  163. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/27.sql +0 -0
  164. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/28.sql +0 -0
  165. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/expected/29.sql +0 -0
  166. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/01.sql +0 -0
  167. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/02.sql +0 -0
  168. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/03.sql +0 -0
  169. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/04.sql +0 -0
  170. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/05.sql +0 -0
  171. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/06.sql +0 -0
  172. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/07.sql +0 -0
  173. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/08.sql +0 -0
  174. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/09.sql +0 -0
  175. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/10.sql +0 -0
  176. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/11.sql +0 -0
  177. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/12.sql +0 -0
  178. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/13.sql +0 -0
  179. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/14.sql +0 -0
  180. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/15.sql +0 -0
  181. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/16.sql +0 -0
  182. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/17.sql +0 -0
  183. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/18.sql +0 -0
  184. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/19.sql +0 -0
  185. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/20.sql +0 -0
  186. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/21.sql +0 -0
  187. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/22.sql +0 -0
  188. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/23.sql +0 -0
  189. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/24.sql +0 -0
  190. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/25.sql +0 -0
  191. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/26.sql +0 -0
  192. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/27.sql +0 -0
  193. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/28.sql +0 -0
  194. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/fixtures/input/29.sql +0 -0
  195. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_align.py +0 -0
  196. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_align_off.py +0 -0
  197. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_align_targets.py +0 -0
  198. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_ast_equiv.py +0 -0
  199. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_atomic_writes.py +0 -0
  200. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_axis_matrix.py +0 -0
  201. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_benchmark_tool.py +0 -0
  202. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_blank_lines.py +0 -0
  203. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_bodylint.py +0 -0
  204. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_boolean_position.py +0 -0
  205. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_casing.py +0 -0
  206. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_clause_order.py +0 -0
  207. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_clauses.py +0 -0
  208. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_cli.py +0 -0
  209. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_comma_joins_lateral_udf.py +0 -0
  210. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_comma_position.py +0 -0
  211. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_comment_and_procedure_bugs.py +0 -0
  212. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_comment_safety.py +0 -0
  213. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_comments.py +0 -0
  214. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_comments_in_predicates.py +0 -0
  215. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_configfile.py +0 -0
  216. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_construct_sweep.py +0 -0
  217. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_corpus.py +0 -0
  218. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_coverage_round_2.py +0 -0
  219. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_ddl.py +0 -0
  220. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_dialect_config.py +0 -0
  221. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_dialect_guard.py +0 -0
  222. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_distinct.py +0 -0
  223. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_dml.py +0 -0
  224. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_docs_examples.py +0 -0
  225. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_expr.py +0 -0
  226. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_fetch_and_lateral_subquery.py +0 -0
  227. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_file_selection.py +0 -0
  228. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_fromjoin.py +0 -0
  229. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_golden.py +0 -0
  230. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_gui.py +0 -0
  231. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_init_config.py +0 -0
  232. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_keyword_case.py +0 -0
  233. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_knob_combinations.py +0 -0
  234. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_line_endings.py +0 -0
  235. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_negated_is_null.py +0 -0
  236. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_nested_constructs.py +0 -0
  237. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_no_silent_declines.py +0 -0
  238. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_on_placement.py +0 -0
  239. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_packaging.py +0 -0
  240. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_pivot.py +0 -0
  241. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_positioning.py +0 -0
  242. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_presets.py +0 -0
  243. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_quoted_column_aliases.py +0 -0
  244. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_remaining_constructs.py +0 -0
  245. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_report.py +0 -0
  246. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_report_growth_and_policy.py +0 -0
  247. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_river.py +0 -0
  248. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_robustness.py +0 -0
  249. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_safety.py +0 -0
  250. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_select_placement.py +0 -0
  251. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_skip.py +0 -0
  252. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_splitter.py +0 -0
  253. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_sqlfluff_coexistence.py +0 -0
  254. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_sqlfluff_gate.py +0 -0
  255. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_sqlglot_conformance.py +0 -0
  256. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_stdin_and_api.py +0 -0
  257. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_style_knobs.py +0 -0
  258. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_subquery.py +0 -0
  259. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_table_alias.py +0 -0
  260. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_table_names.py +0 -0
  261. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_templating.py +0 -0
  262. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_trailing_punctuation.py +0 -0
  263. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_tsql.py +0 -0
  264. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_unaliased_tables.py +0 -0
  265. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_upstream_and_tail.py +0 -0
  266. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_values_and_joins.py +0 -0
  267. {sqlalign-1.2.0 → sqlalign-1.3.0}/tests/test_width_off_and_body_blanks.py +0 -0
  268. {sqlalign-1.2.0 → sqlalign-1.3.0}/tools/benchmark.py +0 -0
  269. {sqlalign-1.2.0 → sqlalign-1.3.0}/tools/build_docs.py +0 -0
  270. {sqlalign-1.2.0 → sqlalign-1.3.0}/tools/docs.css +0 -0
  271. {sqlalign-1.2.0 → sqlalign-1.3.0}/tools/docs.js +0 -0
  272. {sqlalign-1.2.0 → sqlalign-1.3.0}/tools/docs_settings.py +0 -0
  273. {sqlalign-1.2.0 → sqlalign-1.3.0}/tools/fetch_corpus.py +0 -0
  274. {sqlalign-1.2.0 → sqlalign-1.3.0}/tools/shots.py +0 -0
@@ -1,5 +1,210 @@
1
1
  # Changelog
2
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
+
3
208
  ## 1.2.0
4
209
 
5
210
  ### sqlalign no longer respells your statements silently
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sqlalign
3
- Version: 1.2.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
@@ -121,6 +122,29 @@ else is an error unless you pass `--no-strict-config`.
121
122
  `neq_style` · `on_placement` · `preset` · `protect_templating` · `river_gutter` ·
122
123
  `select_indent` · `select_placement` · `table_alias_style` · `width`
123
124
 
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
+
124
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
@@ -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
@@ -16,16 +16,10 @@ sqlalign --dialect tsql report.sql
16
16
 
17
17
  Three things to know before you read the per-dialect sections:
18
18
 
19
- **`--dialect` is a command-line flag only.** It is not a config-file key. Putting
20
- `dialect = "redshift"` in `.sqlalign.toml` is an error, not a silent no-op:
21
-
22
- ```console
23
- $ sqlalign --stdout q.sql
24
- sqlalign: /home/you/warehouse/.sqlalign.toml: unknown setting(s) ['dialect']; 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']
25
- ```
26
-
27
- If a repository holds SQL for more than one engine, run sqlalign once per
28
- directory with the right flag, or use `--exclude` to split the run.
19
+ **The dialect can be declared in the config, or given as a flag.** `--dialect`
20
+ wins for a one-off run; `dialect` in `.sqlalign.toml` is what a repository
21
+ commits. If a repository holds SQL for more than one engine, put a config beside
22
+ each tree rather than running once per directory — see below.
29
23
 
30
24
  **There is no dialect auto-detection.** sqlalign will not sniff your file, and
31
25
  naming the wrong dialect is not covered by the safety guarantee — that guarantee
@@ -73,7 +67,7 @@ twenty-nine golden fixtures are Postgres: selects, joins, `WHERE` with
73
67
  `AND`/`OR`/`IN`/`BETWEEN`/`LIKE`, aggregates, CTEs, subqueries, `CASE`, window
74
68
  functions, set operations, `INSERT`/`UPDATE`/`DELETE`/`MERGE`, nested expressions
75
69
  and comments, `CREATE TABLE`, CTAS, views and materialized views, `CREATE
76
- FUNCTION` and `CREATE PROCEDURE`, `TRUNCATE`, `CREATE INDEX` and `GRANT`.
70
+ FUNCTION` and `CREATE PROCEDURE`, `TRUNCATE`, `CREATE INDEX`, `GRANT` and `REVOKE`.
77
71
 
78
72
  ```console
79
73
  $ sqlalign --stdout query.sql
@@ -157,7 +151,7 @@ Anything without a layout handler passes through byte-identical with a warning.
157
151
 
158
152
  ```console
159
153
  $ sqlalign --stdout declines.sql
160
- sqlalign: declines.sql: unsupported construct, passed through: select * from t pivot (sum(x) for y in (
154
+ sqlalign: declines.sql: unsupported construct (PIVOT: this dialect has no such syntax), passed through: select * from t pivot (sum(x) for y in (
161
155
  select * from t pivot (sum(x) for y in (1, 2)) p;
162
156
  INSERT INTO staging
163
157
  VALUES (1, 2);
@@ -451,8 +445,8 @@ These two are the reason T-SQL needs a guard the other dialects do not.
451
445
 
452
446
  ```console
453
447
  $ sqlalign --stdout --dialect tsql types.sql
454
- sqlalign: types.sql: unsupported construct, passed through: create table t (a real not null, b int);
455
- sqlalign: types.sql: unsupported construct, passed through: select cast(x as ntext) from t;
448
+ sqlalign: types.sql: unsupported construct (tsql: type whose spelling sqlglot cannot preserve), passed through: create table t (a real not null, b int);
449
+ sqlalign: types.sql: unsupported construct (tsql: type whose spelling sqlglot cannot preserve), passed through: select cast(x as ntext) from t;
456
450
  create table t (a real not null, b int);
457
451
  select cast(x as ntext) from t;
458
452
  ```
@@ -224,7 +224,7 @@ sqlalign --stdout passthru.sql
224
224
  ```
225
225
 
226
226
  ```
227
- sqlalign: passthru.sql: unsupported construct (Pivot), passed through: select * from t pivot (sum(x) for y in (
227
+ sqlalign: passthru.sql: unsupported construct (PIVOT: this dialect has no such syntax), passed through: select * from t pivot (sum(x) for y in (
228
228
  ```
229
229
 
230
230
  ```sql
@@ -400,6 +400,29 @@ coexistence config is only the fallback when there is nothing to respect. If
400
400
  you write one by hand rather than generating it, expect `AL01` noise: sqlfluff
401
401
  defaults to requiring `AS` on table aliases, and sqlalign's default omits it.
402
402
 
403
+ ### A shared sqlfluff config
404
+
405
+ `--lint` uses the `.sqlfluff` it finds beside your file, walking upwards the way
406
+ sqlfluff itself does. A config your team keeps outside the repository is not on
407
+ that path, so name it:
408
+
409
+ ```sh
410
+ sqlalign --lint --sqlfluff-config ~/team/shared.sqlfluff models/
411
+ ```
412
+
413
+ It wins over anything discovered. One editor action can then format and report
414
+ your team's findings together — in a JetBrains External Tool, that is
415
+ `--lint --sqlfluff-config /path/to/shared.sqlfluff "$FilePath$"`.
416
+
417
+ It is refused without `--lint`, and refused if the path does not exist: taking a
418
+ config nobody reads would leave you believing your rules had run.
419
+
420
+ **`--lint` reports; it never fixes.** `sqlfluff fix` rewrites SQL — qualifying
421
+ joins, changing cast styles — which is the thing sqlalign does not do, and a
422
+ flag that reads like a reporter is a poor place to hide a rewriter. Run it
423
+ yourself as a second step if you want it; the generated `.sqlfluff` excludes the
424
+ whole `layout` group, so `sqlfluff fix` will not undo the alignment.
425
+
403
426
  ## The settings panel
404
427
 
405
428
  > **The panel is experimental.** It is useful and it is tested, but it is the
@@ -167,7 +167,7 @@ dl.meta dd { margin:0; }
167
167
  <a class="skip" href="#main">Skip to content</a>
168
168
  <header class="top">
169
169
  <a class="brand" href="../index.html">sqlalign</a>
170
- <select class="version" aria-label="Documentation version"><option value="v1" selected>1.2 (current)</option></select>
170
+ <select class="version" aria-label="Documentation version"><option value="v1" selected>1.3 (current)</option></select>
171
171
  <div class="search">
172
172
  <input id="q" type="search" placeholder="Search docs…" autocomplete="off"
173
173
  aria-label="Search documentation">
@@ -540,6 +540,10 @@ warning, so an expected decline is distinguishable from a bug in stderr:</p>
540
540
  <td><code>unsupported construct, passed through: …</code></td>
541
541
  </tr>
542
542
  <tr>
543
+ <td>the render would respell the statement, and casing it from source is not possible either</td>
544
+ <td><code>formatting would respell this statement, passed through unformatted: …</code> — the first half is usually recoverable (see below); this is what is left</td>
545
+ </tr>
546
+ <tr>
543
547
  <td>the output would not AST-compare equal</td>
544
548
  <td><code>formatting would change semantics, passed through unformatted: …</code> — <strong>a bug report</strong>, not a decline: the renderer emitted something that means a different thing</td>
545
549
  </tr>
@@ -553,6 +557,29 @@ warning, so an expected decline is distinguishable from a bug in stderr:</p>
553
557
  </tr>
554
558
  </tbody>
555
559
  </table>
560
+ <p><strong>A respelling is usually recovered rather than declined.</strong> sqlglot's parser
561
+ collapses some pairs of spellings onto one node — <code>ALTER COLUMN x TYPE t</code> and
562
+ <code>SET DATA TYPE t</code> are the same tree — so rendering from the node prints whichever
563
+ the generator prefers. When the token census catches that, the statement is cased
564
+ from its own source instead (<code>sourcecase.py</code>): the source text with keyword spans
565
+ recased and every other byte untouched. Nothing is rebuilt, so nothing can be
566
+ respelt, and the same three checks are re-run against the result.</p>
567
+ <p>Keywords are told from identifiers by the parse tree, not by the keyword table.
568
+ What the author wrote as a name or value is a node; the grammar around it lives
569
+ in the generator and is on no node. A statement sqlglot could only parse as
570
+ <code>exp.Command</code> has no such tree and still passes through.</p>
571
+ <p>The construct in an <code>unsupported construct (…)</code> warning is the node type the
572
+ layout engine declined to model. One node type needs translating: <code>exp.Command</code>
573
+ is sqlglot's catch-all for syntax its parser does not model at all, so it is the
574
+ same word for every unrelated statement that lands there. It is reported under
575
+ the keyword sqlglot kept on the node instead — <code>unsupported construct (SET)</code>
576
+ rather than <code>unsupported construct (Command)</code>.</p>
577
+ <p>sqlglot logs its own fallback for those statements (<code>'SET ROLE reporting' contains unsupported syntax. Falling back to parsing as a 'Command'.</code>). The CLI
578
+ raises that logger to <code>ERROR</code>, because sqlalign reports the same statement by
579
+ name and with the text it passed through — the warning is a second, less
580
+ informative copy on the same stream. The library does not touch the logger:
581
+ <code>sqlalign.format</code> runs inside someone else's program, where silencing a
582
+ dependency is not a formatter's business.</p>
556
583
  <p>One decline is file-wide rather than per statement: a template expression too
557
584
  short to hold a same-width placeholder (<code>{{x}}</code>) fails before splitting, so the
558
585
  whole file passes through with <code>templating not maskable, passed through: …</code>. It
@@ -167,7 +167,7 @@ dl.meta dd { margin:0; }
167
167
  <a class="skip" href="#main">Skip to content</a>
168
168
  <header class="top">
169
169
  <a class="brand" href="../index.html">sqlalign</a>
170
- <select class="version" aria-label="Documentation version"><option value="v1" selected>1.2 (current)</option></select>
170
+ <select class="version" aria-label="Documentation version"><option value="v1" selected>1.3 (current)</option></select>
171
171
  <div class="search">
172
172
  <input id="q" type="search" placeholder="Search docs…" autocomplete="off"
173
173
  aria-label="Search documentation">
@@ -187,7 +187,7 @@ dl.meta dd { margin:0; }
187
187
  <a href="dialects.html">Dialects</a>
188
188
  <a href="architecture.html">Architecture</a>
189
189
  <a href="faq.html">FAQ</a></nav>
190
- <main id="main"><h2 id="all-flags">All flags<a class="anchor" href="#all-flags">#</a></h2><p>Generated from the parser, so it cannot fall behind it. The sections below explain the ones that need more than a line.</p><table><thead><tr><th>Flag</th><th>Description</th></tr></thead><tbody><tr><td><code>-h</code>, <code>--help</code></td><td>show this help message and exit</td></tr><tr><td><code>--version</code></td><td>print the version and exit</td></tr><tr><td><code>--check</code></td><td>do not write; exit 1 if any file would change</td></tr><tr><td><code>--stdout</code></td><td>write the result to stdout instead of the file</td></tr><tr><td><code>--diff</code></td><td>write nothing; print a unified diff of what would change (exit 1 if anything would)</td></tr><tr><td><code>--dialect</code> <code>postgres</code>, <code>redshift</code>, <code>tsql</code></td><td>the SQL dialect to parse and print. Overrides a <code>dialect</code> in the config file (default: postgres)</td></tr><tr><td><code>--line-ending</code> <code>auto</code>, <code>lf</code>, <code>crlf</code></td><td>line endings to write: auto preserves the file's own (default)</td></tr><tr><td><code>--config</code></td><td>use this config file instead of discovering one</td></tr><tr><td><code>--exclude</code></td><td>skip files matching this glob when expanding a directory (repeatable; also settable as <code>exclude</code> in a config file)</td></tr><tr><td><code>--isolated</code></td><td>ignore any config file and use the built-in defaults</td></tr><tr><td><code>--show-config</code></td><td>print the effective settings as TOML and exit</td></tr><tr><td><code>--init</code></td><td>write a commented .sqlalign.toml in the current directory and exit; every setting is commented out, so the file changes nothing until you edit it</td></tr><tr><td><code>--gui</code></td><td>(experimental) open the settings panel with a live preview, and exit</td></tr><tr><td><code>--report</code></td><td>print a coverage summary: how many statements were formatted, and what the rest declined on. Adds output without changing the mode, so on its own it still rewrites; pair it with <code>--check</code> to survey without writing</td></tr><tr><td><code>--max-declines</code></td><td>exit 1 if more than N statements are passed through unformatted (implies --report)</td></tr><tr><td><code>--lint</code></td><td>after formatting, run sqlfluff over the result (needs the optional <code>sqlalign[lint]</code> extra)</td></tr><tr><td><code>--print-sqlfluff-config</code></td><td>print a .sqlfluff that lets sqlfluff run alongside sqlalign without fighting it, and exit</td></tr><tr><td><code>--no-strict-config</code></td><td>warn on unknown config keys instead of failing</td></tr><tr><td><code>--preset</code> <code>compact</code>, <code>dbt</code>, <code>gitlab</code>, <code>house</code>, <code>river</code>, <code>trailing</code></td><td>named starting point; config keys and flags layer on top</td></tr><tr><td><code>--width</code></td><td>column the formatter tries to stay inside; 0 turns it off</td></tr><tr><td><code>--blank-lines-between-statements</code></td><td>force N blank lines between every pair of statements (default: one only between two multi-line statements)</td></tr><tr><td><code>--no-align</code></td><td>emit one space between tokens instead of aligning them into columns (same line structure, no padding)</td></tr><tr><td><code>--no-protect-templating</code></td><td>do not mask Jinja/dbt template expressions before formatting</td></tr><tr><td><code>--no-format-bodies</code></td><td>leave dollar-quoted ($$) procedure and function bodies untouched</td></tr><tr><td><code>--align-targets</code></td><td>comma-separated alignment targets to keep. Default is every target except table_names, which is opt-in because it pads the FROM/JOIN keyword out to a shared table column. Valid: aliases, case_results, column_aliases, column_constraints, column_types, join_conditions, operators, table_aliases, table_names</td></tr><tr><td><code>--comma-position</code> <code>leading</code>, <code>trailing</code></td><td>where the separator comma sits in a stacked list (default: leading)</td></tr><tr><td><code>--boolean-operator-position</code> <code>leading</code>, <code>trailing</code></td><td>where AND/OR sit when a predicate spans lines (default: leading)</td></tr><tr><td><code>--on-placement</code> <code>inline</code>, <code>own_line</code></td><td>whether a JOIN ON rides the table line or drops below it</td></tr><tr><td><code>--select-placement</code> <code>inline</code>, <code>own_line</code></td><td>whether the first select item rides the SELECT line</td></tr><tr><td><code>--select-indent</code></td><td>columns the select list indents under --select-placement own_line (default: 2)</td></tr><tr><td><code>--body-blank-lines</code></td><td>blank lines between the elements of a $$ body (default: 1)</td></tr><tr><td><code>--clause-keyword-align</code> <code>left</code>, <code>river</code></td><td>root clause keywords flush left, or right-aligned to a river</td></tr><tr><td><code>--river-gutter</code></td><td>column a river right-aligns clause keywords to (default: 6)</td></tr><tr><td><code>--keyword-case</code> <code>upper</code>, <code>lower</code></td><td>case for keywords, function names and types (default: upper)</td></tr><tr><td><code>--neq-style</code> <code>!=</code>, <code><></code></td><td>spelling for the not-equal operator (default: !=)</td></tr><tr><td><code>--table-alias-style</code> <code>bare</code>, <code>as</code></td><td>print a table alias as <code>t a</code> (bare) or <code>t AS a</code></td></tr><tr><td><code>--decimal-style</code> <code>NUMERIC</code>, <code>DECIMAL</code></td><td>spelling for the NUMERIC/DECIMAL type (default: NUMERIC)</td></tr></tbody></table><pre><code>sqlalign [OPTIONS] FILE_OR_DIRECTORY...
190
+ <main id="main"><h2 id="all-flags">All flags<a class="anchor" href="#all-flags">#</a></h2><p>Generated from the parser, so it cannot fall behind it. The sections below explain the ones that need more than a line.</p><table><thead><tr><th>Flag</th><th>Description</th></tr></thead><tbody><tr><td><code>-h</code>, <code>--help</code></td><td>show this help message and exit</td></tr><tr><td><code>--version</code></td><td>print the version and exit</td></tr><tr><td><code>--check</code></td><td>do not write; exit 1 if any file would change</td></tr><tr><td><code>--stdout</code></td><td>write the result to stdout instead of the file</td></tr><tr><td><code>--diff</code></td><td>write nothing; print a unified diff of what would change (exit 1 if anything would)</td></tr><tr><td><code>--dialect</code> <code>postgres</code>, <code>redshift</code>, <code>tsql</code></td><td>the SQL dialect to parse and print. Overrides a <code>dialect</code> in the config file (default: postgres)</td></tr><tr><td><code>--lines</code></td><td>format only statements overlapping these 1-based, inclusive line numbers; the rest of the file is left byte-identical. Repeatable. Applies to one file (or stdin), since line numbers mean nothing across several</td></tr><tr><td><code>--line-ending</code> <code>auto</code>, <code>lf</code>, <code>crlf</code></td><td>line endings to write: auto preserves the file's own (default)</td></tr><tr><td><code>--config</code></td><td>use this config file instead of discovering one</td></tr><tr><td><code>--exclude</code></td><td>skip files matching this glob when expanding a directory (repeatable; also settable as <code>exclude</code> in a config file)</td></tr><tr><td><code>--isolated</code></td><td>ignore any config file and use the built-in defaults</td></tr><tr><td><code>--show-config</code></td><td>print the effective settings as TOML and exit</td></tr><tr><td><code>--init</code></td><td>write a commented .sqlalign.toml in the current directory and exit; every setting is commented out, so the file changes nothing until you edit it</td></tr><tr><td><code>--gui</code></td><td>(experimental) open the settings panel with a live preview, and exit</td></tr><tr><td><code>--report</code></td><td>print a coverage summary: how many statements were formatted, and what the rest declined on. Adds output without changing the mode, so on its own it still rewrites; pair it with <code>--check</code> to survey without writing</td></tr><tr><td><code>--max-declines</code></td><td>exit 1 if more than N statements are passed through unformatted (implies --report)</td></tr><tr><td><code>--lint</code></td><td>after formatting, run sqlfluff over the result (needs the optional <code>sqlalign[lint]</code> extra)</td></tr><tr><td><code>--sqlfluff-config</code></td><td>lint with this sqlfluff config instead of the one discovered next to each file. For a shared config that lives outside the repository, which discovery cannot reach. Requires --lint</td></tr><tr><td><code>--print-sqlfluff-config</code></td><td>print a .sqlfluff that lets sqlfluff run alongside sqlalign without fighting it, and exit</td></tr><tr><td><code>--no-strict-config</code></td><td>warn on unknown config keys instead of failing</td></tr><tr><td><code>--preset</code> <code>compact</code>, <code>dbt</code>, <code>gitlab</code>, <code>house</code>, <code>river</code>, <code>trailing</code></td><td>named starting point; config keys and flags layer on top</td></tr><tr><td><code>--width</code></td><td>column the formatter tries to stay inside; 0 turns it off</td></tr><tr><td><code>--blank-lines-between-statements</code></td><td>force N blank lines between every pair of statements (default: one only between two multi-line statements)</td></tr><tr><td><code>--no-align</code></td><td>emit one space between tokens instead of aligning them into columns (same line structure, no padding)</td></tr><tr><td><code>--no-protect-templating</code></td><td>do not mask Jinja/dbt template expressions before formatting</td></tr><tr><td><code>--no-format-bodies</code></td><td>leave dollar-quoted ($$) procedure and function bodies untouched</td></tr><tr><td><code>--align-targets</code></td><td>comma-separated alignment targets to keep. Default is every target except table_names, which is opt-in because it pads the FROM/JOIN keyword out to a shared table column. Valid: aliases, case_results, column_aliases, column_constraints, column_types, join_conditions, operators, table_aliases, table_names</td></tr><tr><td><code>--comma-position</code> <code>leading</code>, <code>trailing</code></td><td>where the separator comma sits in a stacked list (default: leading)</td></tr><tr><td><code>--boolean-operator-position</code> <code>leading</code>, <code>trailing</code></td><td>where AND/OR sit when a predicate spans lines (default: leading)</td></tr><tr><td><code>--on-placement</code> <code>inline</code>, <code>own_line</code></td><td>whether a JOIN ON rides the table line or drops below it</td></tr><tr><td><code>--select-placement</code> <code>inline</code>, <code>own_line</code></td><td>whether the first select item rides the SELECT line</td></tr><tr><td><code>--select-indent</code></td><td>columns the select list indents under --select-placement own_line (default: 2)</td></tr><tr><td><code>--body-blank-lines</code></td><td>blank lines between the elements of a $$ body (default: 1)</td></tr><tr><td><code>--clause-keyword-align</code> <code>left</code>, <code>river</code></td><td>root clause keywords flush left, or right-aligned to a river</td></tr><tr><td><code>--river-gutter</code></td><td>column a river right-aligns clause keywords to (default: 6)</td></tr><tr><td><code>--keyword-case</code> <code>upper</code>, <code>lower</code></td><td>case for keywords, function names and types (default: upper)</td></tr><tr><td><code>--neq-style</code> <code>!=</code>, <code><></code></td><td>spelling for the not-equal operator (default: !=)</td></tr><tr><td><code>--table-alias-style</code> <code>bare</code>, <code>as</code></td><td>print a table alias as <code>t a</code> (bare) or <code>t AS a</code></td></tr><tr><td><code>--decimal-style</code> <code>NUMERIC</code>, <code>DECIMAL</code></td><td>spelling for the NUMERIC/DECIMAL type (default: NUMERIC)</td></tr></tbody></table><pre><code>sqlalign [OPTIONS] FILE_OR_DIRECTORY...
191
191
  </code></pre>
192
192
  <p>Every flag below is the complete set — this page is written against
193
193
  <code>sqlalign --help</code> and nothing is omitted. New to the tool? Start with
@@ -253,6 +253,11 @@ flags change that.</p>
253
253
  <td>Write nothing. Print a unified diff of what would change. Exit <code>1</code> if anything would.</td>
254
254
  </tr>
255
255
  <tr>
256
+ <td><code>--lines START:END</code></td>
257
+ <td>off</td>
258
+ <td>Format only statements overlapping these 1-based, inclusive lines; the rest of the file comes back byte-identical. Repeatable. A bare <code>--lines 12</code> is that one line. Applies to a single file or <code>-</code>.</td>
259
+ </tr>
260
+ <tr>
256
261
  <td><code>--line-ending {auto,lf,crlf}</code></td>
257
262
  <td><code>auto</code></td>
258
263
  <td>Line endings to write. <code>auto</code> preserves each file's own — a CRLF file stays CRLF, and an already-formatted CRLF file does not report a spurious diff.</td>
@@ -360,6 +365,23 @@ else is an error unless you pass <code>--no-strict-config</code>.</p>
360
365
  <code>decimal_style</code> · <code>dialect</code> · <code>exclude</code> · <code>format_dollar_bodies</code> · <code>keyword_case</code> ·
361
366
  <code>neq_style</code> · <code>on_placement</code> · <code>preset</code> · <code>protect_templating</code> · <code>river_gutter</code> ·
362
367
  <code>select_indent</code> · <code>select_placement</code> · <code>table_alias_style</code> · <code>width</code></p>
368
+ <h2 id="formatting-a-selection">Formatting a selection<a class="anchor" href="#formatting-a-selection" aria-label="Link to this section">#</a></h2>
369
+ <pre><code class="language-console">$ sqlalign --lines 40:58 models/orders.sql # just those lines
370
+ $ sqlalign --lines 12 --lines 40:58 orders.sql # two selections
371
+ $ sqlalign --diff --lines 40:58 orders.sql # review before writing
372
+ </code></pre>
373
+ <p><strong>The unit is the statement, not the line.</strong> Half a statement does not parse, so
374
+ a range starting or ending inside one formats that statement entire — which is
375
+ also what a dragged editor selection means. A range that covers only blank lines
376
+ selects nothing and the file is left alone.</p>
377
+ <p>Everything outside the range is byte-identical, including the blank lines around
378
+ it. Asking for line 12 is not asking for the spacing at line 40 to be
379
+ normalised.</p>
380
+ <p>The use this exists for is adopting sqlalign on a repository nobody wants to
381
+ reformat in one commit: format the lines your change touches, leave the rest,
382
+ and the review stays about your change. For an editor filter that hands over
383
+ just the selected text — a visual selection piped through <code>:!</code> in vim — use
384
+ stdin instead: <code>sqlalign -</code> formats what it is given and needs no line numbers.</p>
363
385
  <p><code>--line-ending</code> is the only setting with no config key. Three
364
386
  of the four <code>--no-*</code> flags map onto the positive keys: <code>--no-align</code> is
365
387
  <code>align = false</code>, <code>--no-protect-templating</code> is <code>protect_templating = false</code>, and
@@ -713,7 +735,7 @@ would reformat models/users.sql
713
735
  <p>Exit <code>1</code>. Swap <code>--check</code> for <code>--diff</code> when you want the log to show the change
714
736
  rather than only the filename.</p>
715
737
  </main>
716
- <aside class="toc" aria-label="On this page"><p class="side-h">On this page</p><a class="lvl2" href="#all-flags">All flags</a><a class="lvl2" href="#positional-arguments">Positional arguments</a><a class="lvl2" href="#output-mode">Output mode</a><a class="lvl2" href="#file-selection">File selection</a><a class="lvl2" href="#configuration">Configuration</a><a class="lvl3" href="#valid-config-keys">Valid config keys</a><a class="lvl2" href="#style">Style</a><a class="lvl3" href="#presets">Presets</a><a class="lvl3" href="#alignment-targets">Alignment targets</a><a class="lvl2" href="#exit-codes">Exit codes</a><a class="lvl2" href="#worked-invocations">Worked invocations</a><a class="lvl3" href="#adopt-the-line-structure-without-the-padding">Adopt the line structure without the padding</a><a class="lvl3" href="#keep-the-alignment-move-the-separators-to-end-of-line">Keep the alignment, move the separators to end of line</a><a class="lvl3" href="#drop-on-to-its-own-line">Drop ON to its own line</a><a class="lvl3" href="#lowercase-everything">Lowercase everything</a><a class="lvl3" href="#format-a-dbt-model">Format a dbt model</a><a class="lvl3" href="#give-a-long-window-function-room">Give a long window function room</a><a class="lvl3" href="#space-out-a-migration-script">Space out a migration script</a><a class="lvl3" href="#gate-a-repository-in-ci">Gate a repository in CI</a></aside>
738
+ <aside class="toc" aria-label="On this page"><p class="side-h">On this page</p><a class="lvl2" href="#all-flags">All flags</a><a class="lvl2" href="#positional-arguments">Positional arguments</a><a class="lvl2" href="#output-mode">Output mode</a><a class="lvl2" href="#file-selection">File selection</a><a class="lvl2" href="#configuration">Configuration</a><a class="lvl3" href="#valid-config-keys">Valid config keys</a><a class="lvl2" href="#formatting-a-selection">Formatting a selection</a><a class="lvl2" href="#style">Style</a><a class="lvl3" href="#presets">Presets</a><a class="lvl3" href="#alignment-targets">Alignment targets</a><a class="lvl2" href="#exit-codes">Exit codes</a><a class="lvl2" href="#worked-invocations">Worked invocations</a><a class="lvl3" href="#adopt-the-line-structure-without-the-padding">Adopt the line structure without the padding</a><a class="lvl3" href="#keep-the-alignment-move-the-separators-to-end-of-line">Keep the alignment, move the separators to end of line</a><a class="lvl3" href="#drop-on-to-its-own-line">Drop ON to its own line</a><a class="lvl3" href="#lowercase-everything">Lowercase everything</a><a class="lvl3" href="#format-a-dbt-model">Format a dbt model</a><a class="lvl3" href="#give-a-long-window-function-room">Give a long window function room</a><a class="lvl3" href="#space-out-a-migration-script">Space out a migration script</a><a class="lvl3" href="#gate-a-repository-in-ci">Gate a repository in CI</a></aside>
717
739
  </div>
718
740
  <script>// Docs chrome: theme toggle, version selector, on-this-page highlighting, and
719
741
  // search over the generated index. No dependencies -- the site is static files