niceql 0.1.22 → 0.2.0
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/.travis.yml +4 -3
- data/CHANGELOG.md +19 -0
- data/README.md +5 -2
- data/lib/benchmark/cat.rb +20 -66
- data/lib/benchmark/gsub.rb +23 -14
- data/lib/benchmark/txt +748 -748
- data/lib/niceql/version.rb +1 -1
- data/lib/niceql.rb +17 -18
- data/niceql.gemspec +6 -2
- metadata +43 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f9f1dc89c0c7353d4b8c63056d43968b0ad2f71a602d4e50ba5a48bfa568ed0
|
4
|
+
data.tar.gz: 9fc1ea32fc0ed3053702b3014dbb270457af028e61b6b1bb63ff6c28005d8ce4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0b76948b56fe949aac0b5582081d42a60e35dede01332772c4fb233bd8c14bd2cf1d029187d25e0bb85c20d660f29763d401f2283695f28da36c0053293411c
|
7
|
+
data.tar.gz: 2be8cfca05e187114624a2c70b9318c2dd161c42aca5c3ad90456e2ea2a46cda59de1aadd4d22e8e1111155078fa03b986ce4e7624e809776934eb0c0c94dcb5
|
data/.travis.yml
CHANGED
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
|
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
|

|
@@ -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
|
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
|
15
|
-
|
4
|
+
def slow_plus
|
5
|
+
'foo' + 'bar'
|
16
6
|
end
|
17
7
|
|
18
8
|
# 2 + 1 = 3 object
|
19
|
-
def slow_concat
|
20
|
-
|
9
|
+
def slow_concat
|
10
|
+
'foo'.concat 'bar'
|
21
11
|
end
|
22
12
|
|
23
13
|
# 2 + 1 = 3 object
|
24
|
-
def slow_append
|
25
|
-
|
14
|
+
def slow_append
|
15
|
+
'foo' << 'bar'
|
26
16
|
end
|
27
17
|
|
28
|
-
|
29
|
-
|
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
|
data/lib/benchmark/gsub.rb
CHANGED
@@ -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
|
7
|
-
|
4
|
+
def slow_plus
|
5
|
+
'foo' + 'bar'
|
8
6
|
end
|
9
7
|
|
10
8
|
# 2 + 1 = 3 object
|
11
|
-
def
|
12
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
# 1 object
|
19
|
+
def fast
|
20
|
+
'foo' 'bar'
|
21
|
+
end
|
20
22
|
|
21
|
-
|
22
|
-
|
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
|