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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +19 -0
- data/lib/sql_beautifier/join.rb +14 -2
- data/lib/sql_beautifier/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78f9dbb06e69c39c745f2b3ed880772905a27df060ce64983bc00d7cfd0c7c64
|
|
4
|
+
data.tar.gz: 385db1e7366acc00fe2a3c38a05ef7ddb3510d9a118e585073cf41c5131b81e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
data/lib/sql_beautifier/join.rb
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|