query_console 0.1.0 → 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/README.md +19 -0
- data/app/controllers/query_console/application_controller.rb +6 -3
- data/app/controllers/query_console/explain_controller.rb +47 -0
- data/app/controllers/query_console/queries_controller.rb +2 -0
- data/app/controllers/query_console/schema_controller.rb +32 -0
- data/app/services/query_console/audit_logger.rb +6 -2
- data/app/services/query_console/explain_runner.rb +137 -0
- data/app/services/query_console/schema_introspector.rb +244 -0
- data/app/views/query_console/explain/_results.html.erb +89 -0
- data/app/views/query_console/queries/_results.html.erb +5 -1
- data/app/views/query_console/queries/new.html.erb +720 -328
- data/config/importmap.rb +8 -0
- data/config/routes.rb +5 -0
- data/lib/query_console/configuration.rb +19 -1
- data/lib/query_console/version.rb +1 -1
- metadata +10 -11
data/config/importmap.rb
CHANGED
|
@@ -6,6 +6,14 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js"
|
|
|
6
6
|
pin "@hotwired/stimulus", to: "stimulus.min.js"
|
|
7
7
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
|
|
8
8
|
|
|
9
|
+
# Pin CodeMirror 6 from CDN
|
|
10
|
+
pin "@codemirror/state", to: "https://cdn.jsdelivr.net/npm/@codemirror/state@6.4.0/+esm"
|
|
11
|
+
pin "@codemirror/view", to: "https://cdn.jsdelivr.net/npm/@codemirror/view@6.23.0/+esm"
|
|
12
|
+
pin "@codemirror/language", to: "https://cdn.jsdelivr.net/npm/@codemirror/language@6.10.0/+esm"
|
|
13
|
+
pin "@codemirror/commands", to: "https://cdn.jsdelivr.net/npm/@codemirror/commands@6.3.3/+esm"
|
|
14
|
+
pin "@codemirror/lang-sql", to: "https://cdn.jsdelivr.net/npm/@codemirror/lang-sql@6.6.0/+esm"
|
|
15
|
+
pin "@codemirror/autocomplete", to: "https://cdn.jsdelivr.net/npm/@codemirror/autocomplete@6.13.0/+esm"
|
|
16
|
+
|
|
9
17
|
# Pin application and controllers
|
|
10
18
|
pin "query_console/application", to: "query_console/application.js"
|
|
11
19
|
pin_all_from File.expand_path("../app/javascript/controllers/query_console", __dir__),
|
data/config/routes.rb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
QueryConsole::Engine.routes.draw do
|
|
2
2
|
root to: "queries#new"
|
|
3
3
|
post "run", to: "queries#run"
|
|
4
|
+
post "explain", to: "explain#create"
|
|
5
|
+
|
|
6
|
+
# Schema introspection endpoints
|
|
7
|
+
get "schema/tables", to: "schema#tables"
|
|
8
|
+
get "schema/tables/:name", to: "schema#show", as: :schema_table
|
|
4
9
|
end
|
|
@@ -6,7 +6,15 @@ module QueryConsole
|
|
|
6
6
|
:authorize,
|
|
7
7
|
:current_actor,
|
|
8
8
|
:forbidden_keywords,
|
|
9
|
-
:allowed_starts_with
|
|
9
|
+
:allowed_starts_with,
|
|
10
|
+
:enable_explain,
|
|
11
|
+
:enable_explain_analyze,
|
|
12
|
+
:schema_explorer,
|
|
13
|
+
:schema_cache_seconds,
|
|
14
|
+
:schema_table_denylist,
|
|
15
|
+
:schema_allowlist,
|
|
16
|
+
:enable_syntax_highlighting,
|
|
17
|
+
:enable_autocomplete
|
|
10
18
|
|
|
11
19
|
def initialize
|
|
12
20
|
@enabled_environments = ["development"]
|
|
@@ -20,6 +28,16 @@ module QueryConsole
|
|
|
20
28
|
shutdown backup restore transaction commit rollback
|
|
21
29
|
]
|
|
22
30
|
@allowed_starts_with = %w[select with]
|
|
31
|
+
|
|
32
|
+
# v0.2.0 additions
|
|
33
|
+
@enable_explain = true
|
|
34
|
+
@enable_explain_analyze = false # ANALYZE can be expensive, disabled by default
|
|
35
|
+
@schema_explorer = true
|
|
36
|
+
@schema_cache_seconds = 60
|
|
37
|
+
@schema_table_denylist = ["schema_migrations", "ar_internal_metadata"]
|
|
38
|
+
@schema_allowlist = [] # empty means all tables allowed (except denylist)
|
|
39
|
+
@enable_syntax_highlighting = true
|
|
40
|
+
@enable_autocomplete = true
|
|
23
41
|
end
|
|
24
42
|
end
|
|
25
43
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: query_console
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Johnson Gnanasekar
|
|
@@ -13,9 +13,6 @@ dependencies:
|
|
|
13
13
|
name: rails
|
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
|
15
15
|
requirements:
|
|
16
|
-
- - "~>"
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '7.0'
|
|
19
16
|
- - ">="
|
|
20
17
|
- !ruby/object:Gem::Version
|
|
21
18
|
version: 7.0.0
|
|
@@ -23,9 +20,6 @@ dependencies:
|
|
|
23
20
|
prerelease: false
|
|
24
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
22
|
requirements:
|
|
26
|
-
- - "~>"
|
|
27
|
-
- !ruby/object:Gem::Version
|
|
28
|
-
version: '7.0'
|
|
29
23
|
- - ">="
|
|
30
24
|
- !ruby/object:Gem::Version
|
|
31
25
|
version: 7.0.0
|
|
@@ -77,28 +71,28 @@ dependencies:
|
|
|
77
71
|
requirements:
|
|
78
72
|
- - "~>"
|
|
79
73
|
- !ruby/object:Gem::Version
|
|
80
|
-
version: '
|
|
74
|
+
version: '7.0'
|
|
81
75
|
type: :development
|
|
82
76
|
prerelease: false
|
|
83
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
84
78
|
requirements:
|
|
85
79
|
- - "~>"
|
|
86
80
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '
|
|
81
|
+
version: '7.0'
|
|
88
82
|
- !ruby/object:Gem::Dependency
|
|
89
83
|
name: sqlite3
|
|
90
84
|
requirement: !ruby/object:Gem::Requirement
|
|
91
85
|
requirements:
|
|
92
86
|
- - "~>"
|
|
93
87
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '
|
|
88
|
+
version: '2.0'
|
|
95
89
|
type: :development
|
|
96
90
|
prerelease: false
|
|
97
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
98
92
|
requirements:
|
|
99
93
|
- - "~>"
|
|
100
94
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '
|
|
95
|
+
version: '2.0'
|
|
102
96
|
description: A Rails engine that provides a web-based SQL query console with read-only
|
|
103
97
|
enforcement, authorization hooks, and audit logging.
|
|
104
98
|
email:
|
|
@@ -111,15 +105,20 @@ files:
|
|
|
111
105
|
- README.md
|
|
112
106
|
- Rakefile
|
|
113
107
|
- app/controllers/query_console/application_controller.rb
|
|
108
|
+
- app/controllers/query_console/explain_controller.rb
|
|
114
109
|
- app/controllers/query_console/queries_controller.rb
|
|
110
|
+
- app/controllers/query_console/schema_controller.rb
|
|
115
111
|
- app/javascript/query_console/application.js
|
|
116
112
|
- app/javascript/query_console/controllers/collapsible_controller.js
|
|
117
113
|
- app/javascript/query_console/controllers/editor_controller.js
|
|
118
114
|
- app/javascript/query_console/controllers/history_controller.js
|
|
119
115
|
- app/services/query_console/audit_logger.rb
|
|
116
|
+
- app/services/query_console/explain_runner.rb
|
|
120
117
|
- app/services/query_console/runner.rb
|
|
118
|
+
- app/services/query_console/schema_introspector.rb
|
|
121
119
|
- app/services/query_console/sql_limiter.rb
|
|
122
120
|
- app/services/query_console/sql_validator.rb
|
|
121
|
+
- app/views/query_console/explain/_results.html.erb
|
|
123
122
|
- app/views/query_console/queries/_results.html.erb
|
|
124
123
|
- app/views/query_console/queries/new.html.erb
|
|
125
124
|
- config/importmap.rb
|