niceql 0.6.1 → 0.6.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: 286318425292a968afb8fd83fc05d8067bb03432bdf120ab3412a23119cc4128
4
- data.tar.gz: 1a694bab19fb2281ad3e6b013b4527db6233d55885641eb2b2c76d513309b979
3
+ metadata.gz: f62d4429294ec7ef47e564052b2f5707db818fbb38509bcfc77fdcdc4bb0351f
4
+ data.tar.gz: bfd07f10dc1b7bd99ce81e727eb3afb23bf34dc00fdf2ccf2fcfa9257cb26727
5
5
  SHA512:
6
- metadata.gz: 7398eac94842f0f457e7323603ec21ecdae146b9ceccc84e7191f0d2d4539b8de4447f1fa33206c124bc39b5572d1df8eb054d469ea3f39b929cf6b717367d83
7
- data.tar.gz: f9f4da9487a41a117f08c20416dac9ba8146597301a40c62d162b44013460337ed7015e2674b05d679488b7b6fe7ea9420ae36a244f90c21203eb872b7f0412c
6
+ metadata.gz: 4985d9e128475c93ac6dced329409fc2c6c544de35e6216e723f7d3fbc5baf94584e375d5991fb707f219b57e6129f78d410be24866b1f8e91b79ba5d5f65df7
7
+ data.tar.gz: 7bd016c10244cb5cbb6197e6add3973c47471c7b59f539d0285ca6c5bff04e351df1fbf2c8f77ea2aff4854adca5ec47d6dd1c0666eaec15caf38a854b411a17
@@ -10,7 +10,7 @@ jobs:
10
10
  strategy:
11
11
  fail-fast: false
12
12
  matrix:
13
- ruby: ["2.5", "2.6", "2.7", "3.0", "3.1"]
13
+ ruby: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4"]
14
14
 
15
15
  steps:
16
16
  - uses: actions/checkout@v3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.6.2
2
+ * github CI added 3.2, 3.3, 3.4 to matrix
3
+ * fixed: https://github.com/alekseyl/niceql/issues/25
4
+
1
5
  # 0.6.1
2
6
  * github CI added ( PR: https://github.com/alekseyl/niceql/pull/22 many thnx to @petergoldstein )
3
7
  * issue fixed https://github.com/alekseyl/niceql/issues/23
data/README.md CHANGED
@@ -5,11 +5,7 @@
5
5
  This is a small, nice, simple and zero dependency solution for SQL prettifying for Ruby.
6
6
  It can be used in an irb console without any dependencies ( run bin/console and look for examples ).
7
7
 
8
- Any reasonable suggestions are welcome.
9
-
10
- **Please pay attention: even though issue https://github.com/alekseyl/niceql/issues/16 is resolved
11
- still potentially UPDATE or INSERT request might corrupt your data, please don't patch pg_adapter on production!**
12
-
8
+ Any reasonable suggestions are welcome.
13
9
 
14
10
  ## Before/After
15
11
  ### SQL prettifier:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Niceql
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.2"
5
5
  end
data/lib/niceql.rb CHANGED
@@ -218,7 +218,7 @@ module Niceql
218
218
  # but right now there is no difference between the
219
219
  # newline_wrapped_comment, newline_start_comment, newline_end_comment, they all will be wrapped in newlines
220
220
  COMMENT_AND_LITERAL_TYPES = [:immutable_string, :indentable_string, :inline_comment, :newline_wrapped_comment,
221
- :newline_start_comment, :newline_end_comment,]
221
+ :newline_start_comment, :newline_end_comment]
222
222
 
223
223
  attr_reader :parametrized_sql, :initial_sql, :string_regex, :literals_and_comments_types, :colorize
224
224
 
@@ -236,7 +236,11 @@ module Niceql
236
236
  end
237
237
 
238
238
  def prettified_sql
239
- @parametrized_sql % @guids_to_content.transform_keys(&:to_sym)
239
+ # sprintf or % interpolation will throw an error with standalone '%', but
240
+ # % is a legit operand: https://github.com/alekseyl/niceql/issues/25
241
+ # so it should be escaped via doubling, the easiest way is to do it twice,
242
+ # doubling every %, and then restoring single % for the combination of %%{
243
+ @parametrized_sql.gsub("%", "%%").gsub("%%{", "%{") % @guids_to_content.transform_keys(&:to_sym)
240
244
  end
241
245
 
242
246
  private
@@ -343,7 +347,8 @@ module Niceql
343
347
  # when comment ending with newline followed by a keyword we should remove double newlines
344
348
  def clear_extra_newline_after_comments
345
349
  newlined_comments = @literals_and_comments_types.select { |k,| new_line_ending_comment?(k) }
346
- return if newlined_comments.length == 0
350
+ return if newlined_comments.empty?
351
+
347
352
  parametrized_sql.gsub!(/(#{newlined_comments.keys.join("}\n|")}}\n)/, &:chop)
348
353
  end
349
354
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: niceql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - alekseyl
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-19 00:00:00.000000000 Z
11
+ date: 2025-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  requirements: []
189
- rubygems_version: 3.0.9
189
+ rubygems_version: 3.3.26
190
190
  signing_key:
191
191
  specification_version: 4
192
192
  summary: This is a simple and nice gem for SQL prettifying and formatting. Niceql