sql_beautifier 0.9.0 → 0.9.1

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: c4aaee15f7f4dc7c46c933893b8a02931c5fa83771707ccd22c092ec34ab859d
4
- data.tar.gz: c059346ebc6f54814f8a7c9611ce768f022d8279631e0ca7f3234925f83a2f97
3
+ metadata.gz: 52e4fa6ef07975cadc1b7eaf77dbf0f3000552b1a91268edd22b64a1407f85b0
4
+ data.tar.gz: bcda04e6aecb08a400bedee58ee41b8813030fb202f51e0d1d44365afae72990
5
5
  SHA512:
6
- metadata.gz: b3717a14b1589c8aa1c8f14ffd046f68f385501c60f18ddb2b1330cde847189844d908600531b95b27a160dfebb4d0bb36b9044e25885e590f646a07e00b9f30
7
- data.tar.gz: 52430c788c2ff7ebaf9da5e19c6cd5b1b73431e295fee2fed4b077ee36fabd9334bbbba6f8431c2020e6598bce6883f475cf3be624f898e9ff356b6aa1dff8ad
6
+ metadata.gz: 48911b7894e8251f47c2256da78888ba1fd992f65341d3fa70cc4429d92a7ba7008d4564360eca5e860e91d61f59e0718207abdc61680852e3a8614c478264f3
7
+ data.tar.gz: 5b3c2ab5629a09a6a4c6477c3aaa094f8d03bf1123a1c2cfd1f217ff15463b011d0faf8b8a24e864358ec62a4bf540acc1921400fd0ff7c25d74e2579e3d6e43
data/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## [X.X.X] - YYYY-MM-DD
4
4
 
5
+ ## [0.9.1] - 2026-03-29
6
+
5
7
  ## [0.9.0] - 2026-03-29
6
8
 
7
9
  - Add DML statement formatting for `INSERT`, `UPDATE`, and `DELETE` — each statement type is routed to a dedicated entity class (`InsertQuery`, `UpdateQuery`, `DeleteQuery`) following the `Base` + `parse`/`render` pattern
@@ -15,7 +17,8 @@
15
17
  - Fix `DeleteQuery` silently dropping table aliases (e.g. `DELETE FROM users u WHERE u.id = 1` rendered without the `u` alias, producing invalid SQL) — aliases (with or without `AS`) are now captured and included in the formatted output
16
18
  - Fix `DeleteQuery` mis-parsing `DELETE FROM ONLY <table>` — `ONLY` was read as the table name; the parser now bails out for unsupported modifiers
17
19
  - Fix `InsertQuery` silently dropping unrecognized trailing text after VALUES tuples (e.g. `VALUES (1) foo` would drop `foo`) — remaining text must start with `ON CONFLICT` or `RETURNING`, otherwise the parser bails out
18
- - Fix `DeleteQuery` silently dropping unrecognized text between table/alias and clause keywords — the parser now bails out when remaining text doesn't match any known clause
20
+ - Fix `DeleteQuery` silently dropping unrecognized text between table/alias and clause keywords — the parser now validates remaining text starts with a known clause keyword (`USING`, `WHERE`, `RETURNING`)
21
+ - Fix `InsertQuery` silently dropping trailing commas after VALUES tuples (e.g. `VALUES (1),`) — a comma not followed by another tuple is now treated as a parse failure
19
22
 
20
23
  ## [0.8.0] - 2026-03-29
21
24
 
@@ -4,6 +4,8 @@ module SqlBeautifier
4
4
  class DeleteQuery < Base
5
5
  include DmlRendering
6
6
 
7
+ CLAUSE_KEYWORDS = %w[using where returning].freeze
8
+
7
9
  option :table_name
8
10
  option :table_alias, default: -> {}
9
11
  option :using_clause, default: -> {}
@@ -30,8 +32,12 @@ module SqlBeautifier
30
32
  table_alias = parse_table_alias(scanner)
31
33
 
32
34
  remaining_text = normalized_sql[scanner.position..].strip
35
+ if remaining_text.present?
36
+ remaining_scanner = Scanner.new(remaining_text)
37
+ return nil unless CLAUSE_KEYWORDS.any? { |keyword| remaining_scanner.keyword_at?(keyword) }
38
+ end
39
+
33
40
  clauses = split_delete_clauses(normalized_sql, scanner.position)
34
- return nil if remaining_text.present? && clauses.values.all?(&:nil?)
35
41
 
36
42
  new(
37
43
  table_name: table_name,
@@ -57,8 +63,7 @@ module SqlBeautifier
57
63
  def self.parse_table_alias(scanner)
58
64
  return nil if scanner.finished?
59
65
 
60
- next_keywords = %w[using where returning]
61
- return nil if next_keywords.any? { |keyword| scanner.keyword_at?(keyword) }
66
+ return nil if CLAUSE_KEYWORDS.any? { |keyword| scanner.keyword_at?(keyword) }
62
67
 
63
68
  scanner.skip_past_keyword!("as") if scanner.keyword_at?("as")
64
69
 
@@ -127,6 +127,9 @@ module SqlBeautifier
127
127
  break unless !scanner.finished? && scanner.current_char == Constants::COMMA
128
128
 
129
129
  scanner.advance!
130
+ scanner.skip_whitespace!
131
+
132
+ return [[], values_text] if scanner.finished? || scanner.current_char != Constants::OPEN_PARENTHESIS
130
133
  end
131
134
 
132
135
  remaining_text = values_text[scanner.position..].strip
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SqlBeautifier
4
- VERSION = "0.9.0"
4
+ VERSION = "0.9.1"
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.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kinnell Shah