sql_beautifier 0.10.1 → 0.10.2

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: a1cd21cc5cba64d3579b6d403693f139a96c958d3d5676a885745dee86ca4cb8
4
- data.tar.gz: 03f72e555878220eed0b09646c262e1b70efd678b55fb130d83f8b17d0dcc149
3
+ metadata.gz: 918b0bcf08b9f13dabc26250b303f2b35244cf996877939ac6c31ef7d263dd24
4
+ data.tar.gz: b8daaffc147aaf1556823c3bbc9ca95efdf5070a0747638b2dcc2af14b090e0e
5
5
  SHA512:
6
- metadata.gz: ed584adbe928ae529abd6f3a67896f31d846064795a317e61a3f8074c59e20d27898c5e17e39b78f5d40b74e6e9c4a2bfd7aa99ec6a9cc6ab4ce7fcd776bc31a
7
- data.tar.gz: 9bc2a921e9ba76d00e55fad61f5d34999267d926aed65069981fb3e81b215968c2e60f3958fbf8a67aa645ac13495573396d38f8249bc9871c2df3658ac6c418
6
+ metadata.gz: 3e9188e453a6055bbd79f7c1b4eb0b9aed091a7123d3ce83613e64a82629898022c090845fa36f6a68ff7a51cb692ad97b07dae55b3f1ec5927d196daa267ed7
7
+ data.tar.gz: 89a38090f7fd926e77a54d46d340a50d7b45bd461f49eda0fda865d6801f62ad8ccac2c751f4535cffd6418f1e2f9146f43fd9573e398bcb5113eb01ab022a5e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## [X.X.X] - YYYY-MM-DD
4
4
 
5
+ ## [0.10.2] - 2026-03-30
6
+
7
+ - Fix `INSERT INTO ... (columns) (SELECT ...)` not being recognized — `InsertQuery.parse_body` now unwraps parenthesized SELECT subqueries, supporting PostgreSQL's valid `INSERT INTO table (cols) (SELECT ...)` syntax
8
+
5
9
  ## [0.10.1] - 2026-03-30
6
10
 
7
11
  - Fix nested subquery indentation growing excessively at each depth level — `subquery_base_indent_for` was adding the parent formatter's `depth` to the base indent calculation for subqueries on `from`/`where` lines, double-counting indentation that the parent's `format_as_subquery` would also apply; the method now computes base indentation relative to column 0 of the clause text
@@ -73,6 +73,8 @@ module SqlBeautifier
73
73
  remaining = normalized_sql[scanner.position..].strip
74
74
  scanner.advance!(normalized_sql.length - scanner.position)
75
75
 
76
+ remaining = unwrap_parenthesized_select(remaining)
77
+
76
78
  values_rows = nil
77
79
  select_sql = nil
78
80
  on_conflict_clause = nil
@@ -91,6 +93,15 @@ module SqlBeautifier
91
93
  [values_rows, select_sql, on_conflict_clause, returning_clause]
92
94
  end
93
95
 
96
+ def self.unwrap_parenthesized_select(text)
97
+ return text unless Tokenizer.outer_parentheses_wrap_all?(text)
98
+
99
+ inner_content = Util.strip_outer_parentheses(text)
100
+ return text unless Scanner.new(inner_content).keyword_at?("select")
101
+
102
+ inner_content
103
+ end
104
+
94
105
  def self.split_values_tail(values_text)
95
106
  rows, remaining_text = scan_value_rows(values_text)
96
107
  return [nil, nil, nil] if rows.empty?
@@ -178,7 +189,7 @@ module SqlBeautifier
178
189
  Tokenizer.find_top_level_keyword(text, keyword)
179
190
  end
180
191
 
181
- private_class_method :parse_column_list, :parse_body, :split_values_tail, :scan_value_rows, :split_select_tail, :split_on_conflict_and_returning, :find_top_level_keyword_position
192
+ private_class_method :parse_column_list, :parse_body, :unwrap_parenthesized_select, :split_values_tail, :scan_value_rows, :split_select_tail, :split_on_conflict_and_returning, :find_top_level_keyword_position
182
193
 
183
194
  private
184
195
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SqlBeautifier
4
- VERSION = "0.10.1"
4
+ VERSION = "0.10.2"
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.1
4
+ version: 0.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kinnell Shah