niceql 0.1.25 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +5 -2
- data/lib/niceql/version.rb +1 -1
- data/lib/niceql.rb +16 -17
- data/niceql.gemspec +4 -1
- metadata +38 -11
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/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
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
|
+
|
1
11
|
# 0.1.24/25
|
2
12
|
|
3
13
|
* No features, just strict ruby dependency for >= 2.3,
|
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
|
![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
|
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/niceql/version.rb
CHANGED
data/lib/niceql.rb
CHANGED
@@ -49,7 +49,6 @@ module Niceql
|
|
49
49
|
Niceql.config
|
50
50
|
end
|
51
51
|
|
52
|
-
|
53
52
|
def self.prettify_err(err)
|
54
53
|
prettify_pg_err( err.to_s )
|
55
54
|
end
|
@@ -229,15 +228,20 @@ module Niceql
|
|
229
228
|
|
230
229
|
module ErrorExt
|
231
230
|
def to_s
|
232
|
-
|
233
|
-
Prettifier.prettify_err(super)
|
234
|
-
else
|
235
|
-
super
|
236
|
-
end
|
231
|
+
Niceql.config.prettify_pg_errors ? Prettifier.prettify_err(super) : super
|
237
232
|
end
|
238
233
|
end
|
239
234
|
|
240
235
|
class NiceQLConfig
|
236
|
+
def ar_using_pg_adapter?
|
237
|
+
return false unless defined?(::ActiveRecord::Base)
|
238
|
+
|
239
|
+
adapter = ActiveRecord::Base.try(:connection_db_config).try(:adapter) ||
|
240
|
+
ActiveRecord::Base.try(:connection_config)&.with_indifferent_access&.dig(:adapter)
|
241
|
+
|
242
|
+
adapter == 'postgresql'
|
243
|
+
end
|
244
|
+
|
241
245
|
attr_accessor :pg_adapter_with_nicesql,
|
242
246
|
:indentation_base,
|
243
247
|
:open_bracket_is_newliner,
|
@@ -250,25 +254,20 @@ module Niceql
|
|
250
254
|
self.indentation_base = 2
|
251
255
|
self.open_bracket_is_newliner = false
|
252
256
|
self.prettify_active_record_log_output = false
|
253
|
-
self.prettify_pg_errors =
|
257
|
+
self.prettify_pg_errors = ar_using_pg_adapter?
|
254
258
|
end
|
255
259
|
end
|
256
260
|
|
257
|
-
|
258
261
|
def self.configure
|
259
262
|
yield( config )
|
260
263
|
|
261
|
-
|
262
|
-
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(PostgresAdapterNiceQL)
|
263
|
-
end
|
264
|
+
return unless defined? ::ActiveRecord::Base
|
264
265
|
|
265
|
-
if config.
|
266
|
-
::ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend( AbstractAdapterLogPrettifier )
|
267
|
-
end
|
266
|
+
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(PostgresAdapterNiceQL) if config.pg_adapter_with_nicesql
|
268
267
|
|
269
|
-
if config.
|
270
|
-
|
271
|
-
|
268
|
+
::ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend( AbstractAdapterLogPrettifier ) if config.prettify_active_record_log_output
|
269
|
+
|
270
|
+
::ActiveRecord::StatementInvalid.include( Niceql::ErrorExt ) if config.prettify_pg_errors && config.ar_using_pg_adapter?
|
272
271
|
end
|
273
272
|
|
274
273
|
def self.config
|
data/niceql.gemspec
CHANGED
@@ -31,11 +31,14 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
33
|
spec.required_ruby_version = '>= 2.3'
|
34
|
+
spec.add_development_dependency "activerecord", ">= 6.1"
|
35
|
+
|
34
36
|
spec.add_development_dependency "bundler", ">= 1"
|
35
|
-
spec.add_development_dependency "rake", "
|
37
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
36
38
|
spec.add_development_dependency "minitest", "~> 5.0"
|
37
39
|
|
38
40
|
spec.add_development_dependency "differ"
|
39
41
|
spec.add_development_dependency "pry-byebug"
|
40
42
|
spec.add_development_dependency "benchmark-ips"
|
43
|
+
spec.add_development_dependency 'sqlite3'
|
41
44
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: niceql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- alekseyl
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activerecord
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '6.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '6.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -28,16 +42,16 @@ dependencies:
|
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
47
|
+
version: 12.3.3
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
54
|
+
version: 12.3.3
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: minitest
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,20 @@ dependencies:
|
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sqlite3
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
97
125
|
description: 'This is simple and nice sql prettifier, it splits, indent and colorize
|
98
126
|
SQL query and PG error if any '
|
99
127
|
email:
|
@@ -128,7 +156,7 @@ licenses:
|
|
128
156
|
- MIT
|
129
157
|
metadata:
|
130
158
|
allowed_push_host: https://rubygems.org
|
131
|
-
post_install_message:
|
159
|
+
post_install_message:
|
132
160
|
rdoc_options: []
|
133
161
|
require_paths:
|
134
162
|
- lib
|
@@ -143,9 +171,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
171
|
- !ruby/object:Gem::Version
|
144
172
|
version: '0'
|
145
173
|
requirements: []
|
146
|
-
|
147
|
-
|
148
|
-
signing_key:
|
174
|
+
rubygems_version: 3.1.4
|
175
|
+
signing_key:
|
149
176
|
specification_version: 4
|
150
177
|
summary: This is simple and nice sql prettifier, it splits, indent and colorize SQL
|
151
178
|
query and PG errors if any
|