rails_sql_prettifier 6.1.4 → 7.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -1
- data/CHANGELOG.md +9 -11
- data/Dockerfile_30 +1 -1
- data/README.md +6 -4
- data/docker-compose.yml +2 -3
- data/lib/rails_sql_prettifier/version.rb +1 -1
- data/lib/rails_sql_prettifier.rb +11 -4
- data/rails_sql_prettifier.gemspec +2 -2
- metadata +4 -11
- data/.byebug_history +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdf919f40234cb53ea8a819066c0f83b289a20d25143f130aef38e9145d8c6bb
|
4
|
+
data.tar.gz: 7b137d512642549c1824b50acaaaf4ad123593814316833ac880a49e3cddb195
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1cecf0951a654443dd085c2abf96829af343ea590e9776319cfd9261ad03d5bcd6eb45a65f9c50699a025787ed8c3ca38c574bfd2cee94785f6cad3c252f959
|
7
|
+
data.tar.gz: 2909521fbfc5f49cfe57aae5ffe68a778ebdcaf4a55f725486ead326a2abe2634431ceba0ba736d98bc9ff1340e3b0e647f1b724cc73d9f9bfb3bab1a4d97f0f
|
data/.ruby-gemset
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
rails_sql_prettifier
|
data/CHANGELOG.md
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
#
|
1
|
+
# 7.0.4
|
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
|
+
|
5
|
+
#7.0.3
|
2
6
|
* fixed issue [#20](https://github.com/alekseyl/niceql/issues/20)
|
3
7
|
* adding support for multiple ruby versions testing using docker-compose
|
4
8
|
|
5
|
-
#
|
6
|
-
*
|
7
|
-
|
8
|
-
# 6.1.0
|
9
|
+
#7.0.2
|
10
|
+
* active record versioning is properly aligned now
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
-
* StatementInvalid initialization ahs a breaking change: starting version 6 it has named param sql: for original query )
|
13
|
-
|
14
|
-
ar <= 6.1:
|
15
|
-
* Starting from 6.1 connection_db_config method replaced connection_config which was a hash
|
12
|
+
#7.0.0
|
13
|
+
* current master branch
|
data/Dockerfile_30
CHANGED
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/docker-compose.yml
CHANGED
@@ -3,7 +3,7 @@ version: "3.7"
|
|
3
3
|
services:
|
4
4
|
test:
|
5
5
|
build: .
|
6
|
-
image:
|
6
|
+
image: niceql
|
7
7
|
command: /bin/bash -c 'service postgresql start && rake test'
|
8
8
|
volumes:
|
9
9
|
- '.:/app'
|
@@ -12,8 +12,7 @@ services:
|
|
12
12
|
build:
|
13
13
|
context: .
|
14
14
|
dockerfile: Dockerfile_30
|
15
|
-
image:
|
15
|
+
image: niceql_3_0
|
16
16
|
command: /bin/bash -c 'service postgresql start && rake test'
|
17
17
|
volumes:
|
18
18
|
- '.:/app'
|
19
|
-
|
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,8 +31,8 @@ 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.
|
35
|
-
spec.add_dependency "activerecord", '>=
|
34
|
+
spec.add_dependency "niceql", '~> 0.6'
|
35
|
+
spec.add_dependency "activerecord", '>= 7'
|
36
36
|
|
37
37
|
spec.add_development_dependency "bundler", ">= 1"
|
38
38
|
spec.add_development_dependency "rake", ">= 12.3.3"
|
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:
|
4
|
+
version: 7.0.4
|
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,22 +16,19 @@ 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
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '6.1'
|
34
|
-
- - "<"
|
35
32
|
- !ruby/object:Gem::Version
|
36
33
|
version: '7'
|
37
34
|
type: :runtime
|
@@ -39,9 +36,6 @@ dependencies:
|
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '6.1'
|
44
|
-
- - "<"
|
45
39
|
- !ruby/object:Gem::Version
|
46
40
|
version: '7'
|
47
41
|
- !ruby/object:Gem::Dependency
|
@@ -177,7 +171,6 @@ executables: []
|
|
177
171
|
extensions: []
|
178
172
|
extra_rdoc_files: []
|
179
173
|
files:
|
180
|
-
- ".byebug_history"
|
181
174
|
- ".gitignore"
|
182
175
|
- ".ruby-gemset"
|
183
176
|
- ".ruby-version"
|
data/.byebug_history
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
exit
|
2
|
-
ActiveRecord::Base.connection_db_config.adapter
|
3
|
-
ActiveRecord::Base.connection_db_config.adpter
|
4
|
-
ActiveRecord::Base.connection_db_config
|
5
|
-
c
|
6
|
-
exit
|
7
|
-
si.sql
|
8
|
-
si
|
9
|
-
c
|
10
|
-
sql_body
|
11
|
-
n
|
12
|
-
s
|
13
|
-
original_sql_query
|
14
|
-
err
|
15
|
-
s
|
16
|
-
up
|
17
|
-
s
|
18
|
-
up
|
19
|
-
s
|
20
|
-
up
|
21
|
-
s
|
22
|
-
super
|
23
|
-
try(:sql)
|
24
|
-
Niceql.config.prettify_pg_errors
|
25
|
-
c
|
26
|
-
exit
|
27
|
-
err_template
|
28
|
-
si.to_s
|
29
|
-
exit
|
30
|
-
err_caret_line
|
31
|
-
err_quote_caret_offset
|
32
|
-
c
|
33
|
-
err.lines[1].index( '...' ).to_i
|
34
|
-
err_caret_line
|