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 +4 -4
- data/CHANGELOG.md +4 -1
- data/lib/sql_beautifier/delete_query.rb +8 -3
- data/lib/sql_beautifier/insert_query.rb +3 -0
- 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: 52e4fa6ef07975cadc1b7eaf77dbf0f3000552b1a91268edd22b64a1407f85b0
|
|
4
|
+
data.tar.gz: bcda04e6aecb08a400bedee58ee41b8813030fb202f51e0d1d44365afae72990
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
-
|
|
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
|