sql_beautifier 0.10.6 → 0.10.7

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09f3ec19aa33a9c46efe7403e64d5a2eece5cb2e60ab2a7b1ffc2eda2b48f1c3'
4
- data.tar.gz: da9f80ff35f651f107340f5c2a2c0438e57bbaca81341a93089777b3a04ab1bc
3
+ metadata.gz: 78f9dbb06e69c39c745f2b3ed880772905a27df060ce64983bc00d7cfd0c7c64
4
+ data.tar.gz: 385db1e7366acc00fe2a3c38a05ef7ddb3510d9a118e585073cf41c5131b81e5
5
5
  SHA512:
6
- metadata.gz: ba6bf5c1ef5fb8dc41befbe8fb72a638b64e348c5522aa27e9161b510d5ff47ef5c18f27940f52bb48a136efe7292665dc97080a3b4c982aa9071953a0bece05
7
- data.tar.gz: 76509b388607858b9640dbaf253752f87bdc927d95c7a00f650d98891083a96bc085c94454e252d01d4c12dad77a6dede691bd76c115dd712ee90927e71ec0b6
6
+ metadata.gz: af0d920125b084a1edbcd752a15983269710dd5ebd1f9984be19bf22faf0506e6199fe0a17ae374dddb56cb7739f80521c639a0281a54baaa5d5a30c82509e18
7
+ data.tar.gz: 973796134347efe0b745b11c720cd001c5a99716f08e1c55fb3a97508120ad1a0b7abc603aef360ed0f2f486dee036db675b5e17fa532ceee00fe995dac16b80
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [X.X.X] - YYYY-MM-DD
4
4
 
5
+ ## [0.10.7] - 2026-04-10
6
+
7
+ - Expand parenthesized compound conditions in JOIN `ON` clauses — `ON a = b OR (c = 'd' AND e = f)` now formats the parenthesized group across multiple lines using the same `Condition` rendering as WHERE/HAVING clauses, respecting `inline_group_threshold`
8
+
5
9
  ## [0.10.6] - 2026-04-09
6
10
 
7
11
  - Apply table name formatting to `DELETE ... USING` clause table references — table names in the `USING` clause now follow the `table_name_format` setting (PascalCase by default), matching how table names are formatted in `FROM`, `INSERT INTO`, and CTE definitions
data/README.md CHANGED
@@ -111,6 +111,25 @@ where u.active = true
111
111
  order by o.total desc;
112
112
  ```
113
113
 
114
+ Parenthesized compound conditions in ON clauses are expanded to multiple lines, following the same formatting as WHERE/HAVING groups and respecting `inline_group_threshold`:
115
+
116
+ ```ruby
117
+ SqlBeautifier.call("SELECT users.id FROM users INNER JOIN orders ON orders.user_id = users.id OR (orders.status = 'active' AND orders.verified = true)")
118
+ ```
119
+
120
+ Produces:
121
+
122
+ ```sql
123
+ select u.id
124
+
125
+ from Users u
126
+ inner join Orders o on o.user_id = u.id
127
+ or (
128
+ o.status = 'active'
129
+ and o.verified = true
130
+ );
131
+ ```
132
+
114
133
  Supported join types: `inner join`, `left join`, `right join`, `full join`, `left outer join`, `right outer join`, `full outer join`, `cross join`. The `LATERAL` modifier is supported with `inner join lateral` and `left join lateral` for lateral subqueries.
115
134
 
116
135
  ### DISTINCT and DISTINCT ON
@@ -56,14 +56,17 @@ module SqlBeautifier
56
56
  def render(continuation_indent:, condition_indent:)
57
57
  rendered_table = @table_reference.render(trailing_sentinels: @trailing_sentinels)
58
58
  lateral_prefix = @lateral ? "lateral " : ""
59
+ condition_indent_width = condition_indent.length
59
60
  lines = []
60
61
 
61
62
  if @conditions.any?
62
63
  first_condition = @conditions.first[1]
63
- lines << "#{continuation_indent}#{@keyword} #{lateral_prefix}#{rendered_table} on #{first_condition}"
64
+ formatted_first_condition = format_condition(first_condition, indent_width: condition_indent_width)
65
+ lines << "#{continuation_indent}#{@keyword} #{lateral_prefix}#{rendered_table} on #{formatted_first_condition}"
64
66
 
65
67
  @conditions.drop(1).each do |conjunction, condition|
66
- lines << "#{condition_indent}#{conjunction} #{condition}"
68
+ formatted_condition = format_condition(condition, indent_width: condition_indent_width)
69
+ lines << "#{condition_indent}#{conjunction} #{formatted_condition}"
67
70
  end
68
71
  else
69
72
  lines << "#{continuation_indent}#{@keyword} #{lateral_prefix}#{rendered_table}"
@@ -71,5 +74,14 @@ module SqlBeautifier
71
74
 
72
75
  lines.join("\n")
73
76
  end
77
+
78
+ private
79
+
80
+ def format_condition(condition_text, indent_width:)
81
+ condition_node = Condition.build(nil, condition_text)
82
+ return condition_text if condition_node.leaf?
83
+
84
+ condition_node.render(indent_width: indent_width)
85
+ end
74
86
  end
75
87
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SqlBeautifier
4
- VERSION = "0.10.6"
4
+ VERSION = "0.10.7"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sql_beautifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.6
4
+ version: 0.10.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kinnell Shah