rails_sql_prettifier 6.1.4 → 6.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -4
- data/lib/rails_sql_prettifier/version.rb +1 -1
- data/lib/rails_sql_prettifier.rb +11 -4
- data/rails_sql_prettifier.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df9f5495c84355c3c6a09a4365848d9dfd9e96705b2bd108123d57a4b202b7e
|
4
|
+
data.tar.gz: '02848ff4f8e3d3413e94f48fbc2c7b57077007231ba262f707e4ee56567eefdd'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 936d928a81e4d239bea1133ffc0e962e99f982398aaa5483ad1fc2b90d2bf09b891f1d8baf64cc5a16bdd5acb4250dd0f60c552a671b94ec5c8a0b316b60dd51
|
7
|
+
data.tar.gz: b4d450f3216791ccc8f7888ad5324dd94248724f52c6043f561fedd1eecfa440541a6d0a8845fe0c394b7fbf2a3ed419e6a76cda0acce1aa0edcf444445403cf
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
# 6.1.5
|
2
|
+
* pg_adapter_with_nicesql setting will not be set to action for protected_env
|
3
|
+
* niceql version set to ~> 0.6 (fixed https://github.com/alekseyl/niceql/issues/16 !)
|
4
|
+
|
1
5
|
# 6.1.4
|
2
6
|
* fixed issue [#20](https://github.com/alekseyl/niceql/issues/20)
|
3
7
|
* adding support for multiple ruby versions testing using docker-compose
|
data/README.md
CHANGED
@@ -51,12 +51,14 @@ Or install it yourself as:
|
|
51
51
|
|
52
52
|
```ruby
|
53
53
|
Niceql.configure do |c|
|
54
|
-
# Setting pg_adapter_with_nicesql to true will
|
54
|
+
# Setting pg_adapter_with_nicesql to true will APPLY formatting SQL queries
|
55
55
|
# before execution. Formatted SQL will lead to much better SQL-query debugging and much more clearer error messages
|
56
56
|
# if you are using Postgresql as a data source.
|
57
|
-
# BUT do not use it in production until https://github.com/alekseyl/niceql/issues/16 is resolved
|
58
57
|
#
|
59
|
-
#
|
58
|
+
# BUT even though https://github.com/alekseyl/niceql/issues/16 is resolved,
|
59
|
+
# there could be other potentially uncovered bugs so its better not to
|
60
|
+
# adjust pg_adapter in production, currently there is an additional blocker for that module ProtectedEnv
|
61
|
+
# its will not allow patching PGAdapter for other than test/development envs
|
60
62
|
#
|
61
63
|
# If you need to debug SQL queries in production use exec_niceql
|
62
64
|
#
|
@@ -101,7 +103,7 @@ end
|
|
101
103
|
# only formatting without colorization, you can run output of to_niceql as a SQL query in connection.execute
|
102
104
|
Model.scope.to_niceql
|
103
105
|
|
104
|
-
# prettify PG errors if scope runs with any
|
106
|
+
# will run prettified sql and hence will properly prettify PG errors if scope runs with any
|
105
107
|
Model.scope_with_err.exec_niceql
|
106
108
|
```
|
107
109
|
|
data/lib/rails_sql_prettifier.rb
CHANGED
@@ -2,7 +2,6 @@ require "rails_sql_prettifier/version"
|
|
2
2
|
require 'active_record'
|
3
3
|
require "niceql"
|
4
4
|
|
5
|
-
|
6
5
|
module RailsSQLPrettifier
|
7
6
|
|
8
7
|
module ArExtentions
|
@@ -71,8 +70,8 @@ module RailsSQLPrettifier
|
|
71
70
|
def configure
|
72
71
|
super
|
73
72
|
|
74
|
-
if config.pg_adapter_with_nicesql && defined?(
|
75
|
-
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(
|
73
|
+
if config.pg_adapter_with_nicesql && defined?(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) && !protected_env?
|
74
|
+
::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.include(PostgresAdapterNiceQL)
|
76
75
|
end
|
77
76
|
|
78
77
|
::ActiveRecord::ConnectionAdapters::AbstractAdapter.prepend( AbstractAdapterLogPrettifier ) if config.prettify_active_record_log_output
|
@@ -81,6 +80,13 @@ module RailsSQLPrettifier
|
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
83
|
+
module ProtectedEnv
|
84
|
+
def protected_env?
|
85
|
+
ActiveRecord::Base.connection.migration_context.protected_environment? ||
|
86
|
+
defined?(Rails) && !(Rails.env.test? || Rails.env.development?)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
84
90
|
[::ActiveRecord::Relation,
|
85
91
|
::Arel::TreeManager,
|
86
92
|
::Arel::Nodes::Node].each { |klass| klass.send(:include, ArExtentions) }
|
@@ -89,4 +95,5 @@ module RailsSQLPrettifier
|
|
89
95
|
|
90
96
|
# we need to use a prepend otherwise it's not preceding Niceql.configure in a lookup chain
|
91
97
|
Niceql.singleton_class.prepend( NiceqlExt )
|
92
|
-
|
98
|
+
Niceql.extend(ProtectedEnv)
|
99
|
+
end
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
33
|
spec.required_ruby_version = '>= 2.4'
|
34
|
-
spec.add_dependency "niceql", '~> 0.
|
34
|
+
spec.add_dependency "niceql", '~> 0.6'
|
35
35
|
spec.add_dependency "activerecord", '>= 6.1', '< 7'
|
36
36
|
|
37
37
|
spec.add_development_dependency "bundler", ">= 1"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_sql_prettifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.1.
|
4
|
+
version: 6.1.5
|
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
|
+
date: 2022-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: niceql
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activerecord
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|