niceql 0.1.22 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b00aaefbdb5837f56163c43dfd8c3599add288f5d71e0df6aad33760771562bb
4
- data.tar.gz: 06544b54f77cd4cc54a1b5b44ae8d1438bf57a9b6efc29c9408de7d35c75c8d9
3
+ metadata.gz: 7f9f1dc89c0c7353d4b8c63056d43968b0ad2f71a602d4e50ba5a48bfa568ed0
4
+ data.tar.gz: 9fc1ea32fc0ed3053702b3014dbb270457af028e61b6b1bb63ff6c28005d8ce4
5
5
  SHA512:
6
- metadata.gz: 5580c574b821e14a804252e7f2037341ca3e8c98d9b0b33d22057557cad29b4d1f4701773b2018a29183002280566861ccad962877b29bfcfda0db412d91f69b
7
- data.tar.gz: 9d3ef9a43ab6b97e08c577521486e1b9c0151ba62848a47f096c0d31c521c0ff9b997795d3f8d62b78d4252ad8cd94fad8f8614032847dde5ad2f8fbc28cc830
6
+ metadata.gz: e0b76948b56fe949aac0b5582081d42a60e35dede01332772c4fb233bd8c14bd2cf1d029187d25e0bb85c20d660f29763d401f2283695f28da36c0053293411c
7
+ data.tar.gz: 2be8cfca05e187114624a2c70b9318c2dd161c42aca5c3ad90456e2ea2a46cda59de1aadd4d22e8e1111155078fa03b986ce4e7624e809776934eb0c0c94dcb5
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.4
5
- - 2.5.1
6
- - 2.3.7
4
+ - 2.4
5
+ - 2.5
6
+ - 2.3
7
+ - 2.6
data/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ # 0.2.0
2
+ * Fix to issue https://github.com/alekseyl/niceql/pull/17#issuecomment-924278172. ActiveRecord base config is no longer a hash,
3
+ so it does not have dig method, hence it's breaking the ar_using_pg_adapter? method.
4
+ * active_record added as development dependency :( for proper testing cover.
5
+
6
+ # 0.1.30
7
+ * ActiveRecord pg check for config now will try both connection_db_config and connection_config for adapter verification
8
+ * prettify_pg_errors will not be set to true if ActiveRecord adapter is not using pg, i.e. ar_using_pg_adapter? is false.
9
+ * rake dev dependency bumped according to security issues
10
+
11
+ # 0.1.24/25
12
+
13
+ * No features, just strict ruby dependency for >= 2.3,
14
+ * travis fix for ruby 2.3 and 2.6 added
15
+
16
+ # 0.1.23
17
+ * +LATERAL verb
18
+ * removed hidden rails dependencies PR(https://github.com/alekseyl/niceql/pull/9)
19
+
1
20
  # 0.1.22
2
21
  * multi query formatting
3
22
 
data/README.md CHANGED
@@ -1,10 +1,13 @@
1
1
  # Niceql
2
2
 
3
- This is a small, nice, simple and dependentless solution for SQL prettifiyng for Ruby.
3
+ This is a small, nice, simple and no-dependency solution for SQL prettifying for Ruby.
4
4
  It can be used in an irb console without any dependencies ( run bin/console and look for examples ).
5
5
 
6
6
  Any reasonable suggestions on formatting/coloring are welcome
7
7
 
8
+ **Please pay attention: untill issue https://github.com/alekseyl/niceql/issues/16 is resolved any UPDATE or INSERT request will corrupt your data, don't use on production!**
9
+
10
+
8
11
  ## Before/After
9
12
  ### SQL prettifier:
10
13
  ![alt text](https://github.com/alekseyl/niceql/raw/master/to_niceql.png "To_niceql")
@@ -43,7 +46,7 @@ Niceql.configure do |c|
43
46
  # Setting pg_adapter_with_nicesql to true will force formatting SQL queries
44
47
  # before executing them, this will lead to better SQL-query debugging and much more clearer error messages
45
48
  # if you are using Postgresql as a data source.
46
- # You can adjust pg_adapter in prooduction but do it at your own risk!
49
+ # You can adjust pg_adapter in production but do it at your own risk!
47
50
  # If you need to debug SQL queries in production use exec_niceql
48
51
  # default: false
49
52
  # uncomment next string to enable in development
data/lib/benchmark/cat.rb CHANGED
@@ -1,80 +1,34 @@
1
1
  require 'benchmark/ips'
2
2
 
3
- $str = File.open( './txt' ).readlines.join(' ')
4
-
5
- def str_gen( size, rand_size )
6
- $str[ rand(50000), size + rand(rand_size) ]
7
- end
8
-
9
- def chunk_gen( size )
10
- $str[ rand(50000), size ]
11
- end
12
-
13
3
  # 2 + 1 = 3 object
14
- def slow_plus(size, rand_size )
15
- str_gen(size, rand_size ) + str_gen(size, rand_size )
4
+ def slow_plus
5
+ 'foo' + 'bar'
16
6
  end
17
7
 
18
8
  # 2 + 1 = 3 object
19
- def slow_concat(size, rand_size)
20
- str_gen(size, rand_size ).concat str_gen(size, rand_size )
9
+ def slow_concat
10
+ 'foo'.concat 'bar'
21
11
  end
22
12
 
23
13
  # 2 + 1 = 3 object
24
- def slow_append(size, rand_size)
25
- str_gen(size, rand_size ) << str_gen(size, rand_size )
14
+ def slow_append
15
+ 'foo' << 'bar'
26
16
  end
27
17
 
28
- def fast_interpolation(size, rand_size)
29
- "#{str_gen(size, rand_size )}#{str_gen(size, rand_size )}"
18
+ # 1 object
19
+ def fast
20
+ 'foo' 'bar'
30
21
  end
31
22
 
32
-
33
-
34
- def test_concat(size, rand_size, chunk_size = 1)
35
- Benchmark.ips do |x|
36
- x.report('String#+') { slow_plus(size, rand_size) }
37
- x.report('String#concat') { slow_concat(size, rand_size) }
38
- x.report('String#append') { slow_append(size, rand_size) }
39
- x.report('"#{\'foo\'}#{\'bar\'}"') { fast_interpolation(size, rand_size) }
40
- x.compare!
41
- end
42
-
43
- # Benchmark.ips do |x|
44
- # puts '------------------------------+ chunk----------------'
45
- # x.report('String#+') { str_gen(size, rand_size ) + chunk_gen(chunk_size) }
46
- # x.report('String#concat') { str_gen(size, rand_size ).concat chunk_gen(chunk_size) }
47
- # x.report('String#append') { str_gen(size, rand_size ) << chunk_gen(chunk_size) }
48
- # x.report('"#{\'foo\'}#{\'bar\'}"') { "#{str_gen(size, rand_size )}#{chunk_gen(chunk_size)}" }
49
- # x.compare!
50
- # end
51
- #
52
- # Benchmark.ips do |x|
53
- # puts '------------------------------chunk +----------------'
54
- # x.report('String#+') { str_gen(size, rand_size ) + chunk_gen(chunk_size) }
55
- # x.report('String#concat') { str_gen(size, rand_size ).concat chunk_gen(chunk_size) }
56
- # x.report('String#append') { str_gen(size, rand_size ) << chunk_gen(chunk_size) }
57
- # x.report('"#{\'foo\'}#{\'bar\'}"') { "#{str_gen(size, rand_size )}#{chunk_gen(chunk_size)}" }
58
- # x.compare!
59
- # end
60
-
61
-
62
- Benchmark.ips do |x|
63
- puts '------------------------------triple spaced----------------'
64
- x.report('String#+') { str_gen(size, rand_size ) + ' '+ str_gen(size, rand_size) }
65
- x.report('String#concat') { str_gen(size, rand_size ).concat(' ').concat( str_gen(size, rand_size ) )}
66
- x.report('String#append') { str_gen(size, rand_size ) << ' ' << str_gen(size, rand_size ) }
67
- x.report('"#{\'foo\'}#{\'bar\'}"') { "#{str_gen(size, rand_size )} #{chunk_gen(chunk_size)}" }
68
- x.compare!
69
- end
70
-
71
-
72
- Benchmark.ips do |x|
73
- puts '------------------------------triple spaced----------------'
74
- x.report('String#+') { str_gen(size, rand_size ) + str_gen(size, rand_size ) + str_gen(size, rand_size) }
75
- x.report('String#concat') { str_gen(size, rand_size ).concat(str_gen(size, rand_size )).concat( str_gen(size, rand_size ) )}
76
- x.report('String#append') { str_gen(size, rand_size ) << str_gen(size, rand_size ) << str_gen(size, rand_size ) }
77
- x.report('"#{\'foo\'}#{\'bar\'}"') { "#{str_gen(size, rand_size )}#{str_gen(size, rand_size )}#{chunk_gen(chunk_size)}" }
78
- x.compare!
79
- end
23
+ def fast_interpolation
24
+ "#{'foo'}#{'bar'}"
80
25
  end
26
+
27
+ Benchmark.ips do |x|
28
+ x.report('String#+') { slow_plus }
29
+ x.report('String#concat') { slow_concat }
30
+ x.report('String#append') { slow_append }
31
+ x.report('"foo" "bar"') { fast }
32
+ x.report('"#{\'foo\'}#{\'bar\'}"') { fast_interpolation }
33
+ x.compare!
34
+ end
@@ -1,25 +1,34 @@
1
1
  require 'benchmark/ips'
2
2
 
3
- $str = File.open( './txt' ).readlines.join(' ')
4
-
5
3
  # 2 + 1 = 3 object
6
- def _gsub(str)
7
- str.gsub( /\s+/, '' )
4
+ def slow_plus
5
+ 'foo' + 'bar'
8
6
  end
9
7
 
10
8
  # 2 + 1 = 3 object
11
- def _gsub!(str)
12
- str.gsub!( /\s+/, '' )
9
+ def slow_concat
10
+ 'foo'.concat 'bar'
13
11
  end
14
12
 
13
+ # 2 + 1 = 3 object
14
+ def slow_append
15
+ 'foo' << 'bar'
16
+ end
15
17
 
16
- def test_gsubs( word_count, string_count = 1000 )
17
- arr = Array.new( string_count ) { $str.split.sample(word_count).join(' ') }
18
-
19
- Benchmark.ips do |x|
18
+ # 1 object
19
+ def fast
20
+ 'foo' 'bar'
21
+ end
20
22
 
21
- x.report('_gsub!') { arr.each{ |str| _gsub!(str) } }
22
- x.report('_gsub') { arr.each{ |str| _gsub(str) } }
23
- x.compare!
24
- end
23
+ def fast_interpolation
24
+ "#{'foo'}#{'bar'}"
25
25
  end
26
+
27
+ Benchmark.ips do |x|
28
+ x.report('String#+') { slow_plus }
29
+ x.report('String#concat') { slow_concat }
30
+ x.report('String#append') { slow_append }
31
+ x.report('"foo" "bar"') { fast }
32
+ x.report('"#{\'foo\'}#{\'bar\'}"') { fast_interpolation }
33
+ x.compare!
34
+ end