niceql 0.1.23 → 0.3.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: 1dfcafe0d0be8d92b64b06342910568796ddc264a914a930e8bd183ace83f1e9
4
- data.tar.gz: 19b896ec5e2e36c637f3bd7cff237cfff26581c211702d640e7fcd5a782832a9
3
+ metadata.gz: d33cb207d137e2c0e3b3fe59c2b9d525878a6def4a0be7b178b3555c98417148
4
+ data.tar.gz: c02577dea05cb51e74f1478be10241c7e6ef5a4554a92ef38da85b706fb11737
5
5
  SHA512:
6
- metadata.gz: e801df8dd07905db21ff697b7961a10d80a67895ad1f5cf991e68f11e24fc1942fa9d7a196a3a9a30cb4b992d002a38daef19deb1e235c7f5baeadd72e167065
7
- data.tar.gz: 3b4e129aa6a0b49178c809239feb346a454e50da6cd8d930a4b465b16a29078ae23df99d14c9b90536671c3475af9e31f3f24de7535626ac4919f03bbe4cddd3
6
+ metadata.gz: 7e03b3cbb34a26b1bc246b3aba84a775fca4cd0aaac2c87ed7b8310cbf3c796c3afa81d0407f3282d4bc888356c179ce1ce5bb88cb2cfbbcc5e1c959de00a24e
7
+ data.tar.gz: 21a7493a4c284fb2d24866dab5d39b71eece8507a6f066bb7226bcfd25b28f2e60ec2dcea5c12134413458dda1076f815bda3f8d759cee341114dd8000e99af0
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,18 @@
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
+
1
16
  # 0.1.23
2
17
  * +LATERAL verb
3
18
  * removed hidden rails dependencies PR(https://github.com/alekseyl/niceql/pull/9)
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